Skip to content

Commit e48f971

Browse files
committed
test - scaffolding spec - Add UserControllerSpec
1 parent c5d8adc commit e48f971

File tree

3 files changed

+125
-0
lines changed

3 files changed

+125
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package com.example
21+
22+
import com.example.pages.LoginPage
23+
24+
import grails.plugin.geb.ContainerGebSpec
25+
import grails.testing.mixin.integration.Integration
26+
27+
@Integration(applicationClass = Application)
28+
class UserControllerSpec extends ContainerGebSpec {
29+
30+
void setup() {
31+
go '/'
32+
to LoginPage
33+
username = '[email protected]'
34+
password = 'letmein'
35+
loginButton.click()
36+
}
37+
38+
void cleanup() {
39+
try {
40+
go 'logout'
41+
$('input', value: 'Log Out').click()
42+
}
43+
catch (ignored) {
44+
// ignored
45+
}
46+
}
47+
48+
void "User list"() {
49+
when:
50+
go 'user/index'
51+
52+
then:
53+
title == 'User List'
54+
}
55+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package com.example.pages
21+
22+
import geb.Page
23+
24+
class LoginPage extends Page {
25+
26+
static url = 'login'
27+
28+
static at = { title == 'Please sign in' }
29+
30+
static content = {
31+
loginForm { $('form.login-form') }
32+
username { $('input', name: 'username') }
33+
password { $('input', name: 'password') }
34+
loginButton { $('button.primary', type: 'submit') }
35+
}
36+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package com.example.pages
21+
22+
import geb.Page
23+
24+
class LogoutPage extends Page {
25+
26+
static url = 'logout'
27+
28+
static at = { title == 'Confirm Log Out?' }
29+
30+
static content = {
31+
logoutForm { $('form') }
32+
logoutButton { $('button', value: 'Log Out') }
33+
}
34+
}

0 commit comments

Comments
 (0)