Last change
on this file since 947 was
947,
checked in by gav, 13 years ago
|
Enhance and refactor functional tests to use pageId (for at{} verify) in main.gsp layout.
|
File size:
1.3 KB
|
Line | |
---|
1 | package gnumims.functional.pages |
---|
2 | |
---|
3 | import geb.Page |
---|
4 | |
---|
5 | /** |
---|
6 | * http://ldaley.com/post/1013531080/painless-page-identification-with-geb-grails |
---|
7 | */ |
---|
8 | abstract class GrailsPage extends Page { |
---|
9 | |
---|
10 | // To be overridden by subclasses |
---|
11 | static controller = null |
---|
12 | static action = null |
---|
13 | static url = "$controller/$action" |
---|
14 | |
---|
15 | static at = { |
---|
16 | // delegate here is the original page _instance_ (i.e. the subclass) |
---|
17 | |
---|
18 | def expectedPageControllerName = delegate.class.controller |
---|
19 | if (expectedPageControllerName == null) { |
---|
20 | throw new IllegalStateException("${delegate.class} forgot to declare which controller it belongs to") |
---|
21 | } |
---|
22 | |
---|
23 | def expectedPageActionName = delegate.class.action |
---|
24 | if (expectedPageActionName == null) { |
---|
25 | throw new IllegalStateException("${delegate.class} forgot to declare which action it is") |
---|
26 | } |
---|
27 | |
---|
28 | def actualPageControllerName = controllerName |
---|
29 | def actualPageActionName = actionName |
---|
30 | |
---|
31 | assert actualPageControllerName == expectedPageControllerName |
---|
32 | assert actualPageActionName == expectedPageActionName |
---|
33 | |
---|
34 | true // at checkers must return true |
---|
35 | } |
---|
36 | |
---|
37 | static content = { |
---|
38 | pageId { $("meta", name: "pageId").@content } |
---|
39 | controllerName { pageId.split('\\.')[0] } |
---|
40 | actionName { pageId.split('\\.')[1] } |
---|
41 | } |
---|
42 | |
---|
43 | } |
---|
44 | |
---|
Note: See
TracBrowser
for help on using the repository browser.