watirmark 5.14.16 → 5.27.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/watirmark +2 -8
- data/generators/new_project/generator.rb +58 -0
- data/{app_generators/create_project/templates/project → generators/new_project/templates}/config.yml.erb +0 -0
- data/{app_generators/create_project → generators/new_project}/templates/features/env.rb.erb +0 -0
- data/{app_generators/create_project → generators/new_project}/templates/features/model_steps.rb.erb +0 -0
- data/{app_generators/create_project → generators/new_project}/templates/features/post_error_steps.rb.erb +0 -0
- data/{app_generators/create_project → generators/new_project}/templates/features/sample.feature.erb +0 -0
- data/{app_generators/create_project → generators/new_project}/templates/features/site_steps.rb.erb +0 -0
- data/generators/new_project/templates/gemfile.rb.erb +10 -0
- data/generators/new_project/templates/generators/mvc/generator.rb.erb +61 -0
- data/generators/new_project/templates/generators/mvc/templates/controller.rb.erb +9 -0
- data/generators/new_project/templates/generators/mvc/templates/model.rb.erb +7 -0
- data/generators/new_project/templates/generators/mvc/templates/view.rb.erb +16 -0
- data/{app_generators/create_project/templates/library → generators/new_project/templates/lib}/configuration.rb.erb +0 -0
- data/{app_generators/create_project/templates/library → generators/new_project/templates/lib}/core_libraries.rb.erb +0 -0
- data/{app_generators/create_project/templates/library → generators/new_project/templates/lib}/loader.rb.erb +0 -0
- data/{app_generators/create_project/templates/library → generators/new_project/templates/lib/name/checkers}/page_load_checker.rb.erb +0 -0
- data/{app_generators/create_project/templates/library → generators/new_project/templates/lib/name/checkers}/post_errors_checker.rb.erb +0 -0
- data/{app_generators/create_project/templates/library → generators/new_project/templates/lib/name/site}/base_controller.rb.erb +0 -0
- data/{app_generators/create_project/templates/library → generators/new_project/templates/lib/name/site}/base_view.rb.erb +0 -0
- data/{app_generators/create_project/templates/library → generators/new_project/templates/lib/name/site}/search_controller.rb.erb +0 -0
- data/{app_generators/create_project/templates/library/project_require_file.rb.erb → generators/new_project/templates/lib/name.rb.erb} +0 -0
- data/{app_generators/create_project/templates/library → generators/new_project/templates/lib}/workflows.rb.erb +0 -0
- data/{app_generators/create_project/templates/project → generators/new_project/templates}/rakefile.rb.erb +1 -1
- data/generators/new_project/templates/script/generate.rb.erb +4 -0
- data/lib/watirmark/at_exit.rb +5 -9
- data/lib/watirmark/configuration.rb +7 -2
- data/lib/watirmark/controller/actions.rb +35 -12
- data/lib/watirmark/controller/controller.rb +8 -4
- data/lib/watirmark/controller/dialogs.rb +3 -3
- data/lib/watirmark/cucumber/email_helper.rb +19 -0
- data/lib/watirmark/cucumber/env.rb +6 -5
- data/lib/watirmark/cucumber/hook_helper.rb +38 -0
- data/lib/watirmark/cucumber/hooks.rb +13 -8
- data/lib/watirmark/cucumber/load_cached_models.rb +9 -0
- data/lib/watirmark/cucumber/model_helper.rb +4 -4
- data/lib/watirmark/cucumber/transforms.rb +3 -1
- data/lib/watirmark/extensions/ruby_extensions.rb +8 -0
- data/lib/watirmark/extensions/webdriver_extensions.rb +38 -3
- data/lib/watirmark/formatters/snapshot_formatter.rb +3 -0
- data/lib/watirmark/models/cucumber_helper.rb +12 -5
- data/lib/watirmark/models/factory.rb +35 -2
- data/lib/watirmark/page/page.rb +1 -0
- data/lib/watirmark/page/page_definition.rb +7 -5
- data/lib/watirmark/profile.rb +2 -2
- data/lib/watirmark/rake/smoketest.rb +6 -4
- data/lib/watirmark/screenshot.rb +3 -8
- data/lib/watirmark/session.rb +105 -9
- data/lib/watirmark/version.rb +1 -1
- data/lib/watirmark.rb +1 -8
- data/spec/config_spec.rb +45 -37
- data/spec/controller_actions_spec.rb +70 -7
- data/spec/controller_spec.rb +103 -83
- data/spec/model_factory_spec.rb +191 -8
- data/spec/model_traits_spec.rb +5 -0
- data/spec/page_spec.rb +10 -2
- data/spec/process_page_spec.rb +3 -3
- data/spec/session_spec.rb +56 -0
- data/spec/spec_helper.rb +1 -1
- metadata +146 -142
- data/app_generators/create_project/create_project_generator.rb +0 -115
- data/app_generators/create_project/templates/generators/controller.rb.erb +0 -9
- data/app_generators/create_project/templates/generators/generate.rb.erb +0 -9
- data/app_generators/create_project/templates/generators/model.rb.erb +0 -7
- data/app_generators/create_project/templates/generators/mvc_generator.rb.erb +0 -100
- data/app_generators/create_project/templates/generators/rbeautify.rb.erb +0 -212
- data/app_generators/create_project/templates/generators/view.rb.erb +0 -16
- data/app_generators/create_project/templates/generators/workflow_loader.rb.erb +0 -1
- data/app_generators/create_project/templates/project/gemfile.rb.erb +0 -11
- data/bin/etapestry/Gemfile +0 -11
- data/bin/etapestry/config.yml +0 -3
- data/bin/etapestry/features/etapestry_home.feature +0 -5
- data/bin/etapestry/features/step_definitions/model_steps.rb +0 -9
- data/bin/etapestry/features/step_definitions/post_error_steps.rb +0 -15
- data/bin/etapestry/features/step_definitions/site_steps.rb +0 -7
- data/bin/etapestry/features/support/env.rb +0 -8
- data/bin/etapestry/generators/mvc/mvc_generator.rb +0 -100
- data/bin/etapestry/generators/mvc/rbeautify.rb +0 -212
- data/bin/etapestry/generators/mvc/templates/controller.rb.erb +0 -9
- data/bin/etapestry/generators/mvc/templates/model.rb.erb +0 -7
- data/bin/etapestry/generators/mvc/templates/view.rb.erb +0 -16
- data/bin/etapestry/generators/mvc/templates/workflow_loader.rb.erb +0 -1
- data/bin/etapestry/lib/etapestry/checkers/page_load_checker.rb +0 -11
- data/bin/etapestry/lib/etapestry/checkers/post_errors_checker.rb +0 -23
- data/bin/etapestry/lib/etapestry/configuration.rb +0 -6
- data/bin/etapestry/lib/etapestry/core_libraries.rb +0 -9
- data/bin/etapestry/lib/etapestry/loader.rb +0 -23
- data/bin/etapestry/lib/etapestry/site/base_controller.rb +0 -9
- data/bin/etapestry/lib/etapestry/site/base_view.rb +0 -6
- data/bin/etapestry/lib/etapestry/site/search_controller.rb +0 -12
- data/bin/etapestry/lib/etapestry/workflows.rb +0 -0
- data/bin/etapestry/lib/etapestry.rb +0 -8
- data/bin/etapestry/rakefile.rb +0 -21
- data/bin/etapestry/script/generate.rb +0 -9
- data/bin/twitter/features/hashtag_search.feature +0 -93
- data/bin/twitter/features/step_definitions/hashtag_steps.rb +0 -9
- data/bin/twitter/lib/twitter/workflows/search/result_controller.rb +0 -13
- data/bin/twitter/lib/twitter/workflows/search/result_model.rb +0 -5
- data/bin/twitter/lib/twitter/workflows/search/result_view.rb +0 -19
@@ -13,6 +13,9 @@ describe Watirmark::Actions do
|
|
13
13
|
def create
|
14
14
|
end
|
15
15
|
|
16
|
+
def create_until(&block)
|
17
|
+
end
|
18
|
+
|
16
19
|
def edit
|
17
20
|
end
|
18
21
|
|
@@ -32,8 +35,8 @@ describe Watirmark::Actions do
|
|
32
35
|
class ActionModel < Watirmark::Model::Factory
|
33
36
|
keywords :a, :b
|
34
37
|
defaults do
|
35
|
-
a {1}
|
36
|
-
b {2}
|
38
|
+
a { 1 }
|
39
|
+
b { 2 }
|
37
40
|
end
|
38
41
|
end
|
39
42
|
end
|
@@ -69,8 +72,8 @@ describe Watirmark::Actions do
|
|
69
72
|
|
70
73
|
it 'records should be processed separately' do
|
71
74
|
controller = ActionController.new
|
72
|
-
controller.records << {a:1, b:2}
|
73
|
-
controller.records << {c:3, d:4}
|
75
|
+
controller.records << {a: 1, b: 2}
|
76
|
+
controller.records << {c: 3, d: 4}
|
74
77
|
controller.expects(:before_all).once
|
75
78
|
controller.expects(:after_all).once
|
76
79
|
controller.expects(:before_each).twice
|
@@ -81,11 +84,71 @@ describe Watirmark::Actions do
|
|
81
84
|
it 'records should be cleared after run' do
|
82
85
|
controller = ActionController.new
|
83
86
|
controller.records.should == []
|
84
|
-
controller.records << {a:1, b:2}
|
85
|
-
controller.records << {c:3, d:4}
|
86
|
-
controller.records.should == [{a:1, b:2}, {c:3, d:4}]
|
87
|
+
controller.records << {a: 1, b: 2}
|
88
|
+
controller.records << {c: 3, d: 4}
|
89
|
+
controller.records.should == [{a: 1, b: 2}, {c: 3, d: 4}]
|
87
90
|
controller.run :create
|
88
91
|
controller.records.should == []
|
89
92
|
end
|
90
93
|
|
94
|
+
it 'records can be assigned models' do
|
95
|
+
controller = ActionController.new
|
96
|
+
controller.records << ModelOpenStruct.new(:a => 1, :b => 2)
|
97
|
+
controller.run :create
|
98
|
+
controller.model.a.should == 1
|
99
|
+
controller.model.b.should == 2
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'records should be processed separately when models are given' do
|
103
|
+
controller = ActionController.new
|
104
|
+
controller.records << ModelOpenStruct.new(:a => 1, :b => 2)
|
105
|
+
controller.records << ModelOpenStruct.new(:c => 3, :d => 4)
|
106
|
+
controller.run :create
|
107
|
+
controller.model.a.should == nil
|
108
|
+
controller.model.b.should == nil
|
109
|
+
controller.model.c.should == 3
|
110
|
+
controller.model.d.should == 4
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'run can accept a block for the stop_until methods' do
|
114
|
+
@controller.expects(:before_all).once
|
115
|
+
@controller.expects(:after_all).once
|
116
|
+
@controller.run(:create_until){ eval "true"}
|
117
|
+
end
|
118
|
+
|
119
|
+
module ControllerActionsTest
|
120
|
+
class Element
|
121
|
+
attr_accessor :value
|
122
|
+
|
123
|
+
def wait_until_present
|
124
|
+
true
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
class ActionCreateView < Page
|
129
|
+
keyword(:a) { Element.new }
|
130
|
+
keyword(:b) { Element.new }
|
131
|
+
|
132
|
+
def create(*args)
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
class ActionCreateController < Watirmark::WebPage::Controller
|
138
|
+
@view = ActionCreateView
|
139
|
+
end
|
140
|
+
|
141
|
+
class ActionCreateControllerWithOverride < ActionCreateController
|
142
|
+
def populate_data
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'should not throw an exception if anything is populated' do
|
148
|
+
expect { ControllerActionsTest::ActionCreateController.new(:a => 1).create }.not_to raise_error
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should not throw an exception if populate_data is overridden' do
|
152
|
+
lambda { ControllerActionsTest::ActionCreateControllerWithOverride.new.create }.should_not raise_error
|
153
|
+
end
|
91
154
|
end
|
data/spec/controller_spec.rb
CHANGED
@@ -3,13 +3,14 @@ require_relative 'spec_helper'
|
|
3
3
|
describe Watirmark::WebPage::Controller do
|
4
4
|
|
5
5
|
class TestView < Page
|
6
|
-
keyword(:text_field)
|
7
|
-
keyword(:select_list) {browser.select_list(:name, 'select_list')}
|
8
|
-
keyword(:another_text_field)
|
6
|
+
keyword(:text_field) { browser.text_field(:name, 'text_field') }
|
7
|
+
keyword(:select_list) { browser.select_list(:name, 'select_list') }
|
8
|
+
keyword(:another_text_field) { browser.text_field(:id, 'validate1') }
|
9
9
|
end
|
10
10
|
|
11
11
|
class TestController < Watirmark::WebPage::Controller
|
12
12
|
@view = TestView
|
13
|
+
|
13
14
|
def initialize(*args)
|
14
15
|
super
|
15
16
|
@model.text_field = 'foobar'
|
@@ -17,49 +18,57 @@ describe Watirmark::WebPage::Controller do
|
|
17
18
|
end
|
18
19
|
|
19
20
|
class VerifyView < Page
|
20
|
-
keyword(:validate1)
|
21
|
-
keyword(:validate2)
|
22
|
-
keyword(:validate3)
|
23
|
-
keyword(:validate4)
|
24
|
-
keyword(:checkbox)
|
21
|
+
keyword(:validate1) { browser.text_field(:id, 'validate1') }
|
22
|
+
keyword(:validate2) { browser.text_field(:id, 'validate2') }
|
23
|
+
keyword(:validate3) { browser.text_field(:id, 'validate3') }
|
24
|
+
keyword(:validate4) { browser.select_list(:id, 'validate3') }
|
25
|
+
keyword(:checkbox) { browser.checkbox(:id, 'checkbox') }
|
25
26
|
|
26
|
-
verify_keyword(:label1)
|
27
|
-
verify_keyword(:value1)
|
28
|
-
populate_keyword(:populate1) {browser.text_field(:id, 'validate4')}
|
29
|
-
populate_keyword(:populate2) {browser.td(:id, 'value1')}
|
27
|
+
verify_keyword(:label1) { browser.td(:id, 'label1') }
|
28
|
+
verify_keyword(:value1) { browser.td(:id, 'value1') }
|
29
|
+
populate_keyword(:populate1) { browser.text_field(:id, 'validate4') }
|
30
|
+
populate_keyword(:populate2) { browser.td(:id, 'value1') }
|
30
31
|
|
31
|
-
private_keyword(:private_validate1)
|
32
|
-
navigation_keyword(:click_submit)
|
32
|
+
private_keyword(:private_validate1) { browser.text_field(:id, 'validate1') }
|
33
|
+
navigation_keyword(:click_submit) { browser.button(:id, 'Submit').click }
|
33
34
|
end
|
34
35
|
|
35
36
|
class VerifyController < Watirmark::WebPage::Controller
|
36
|
-
|
37
|
+
@view = VerifyView
|
37
38
|
end
|
38
39
|
|
39
|
-
class TestControllerSubclass < TestController;
|
40
|
+
class TestControllerSubclass < TestController;
|
41
|
+
end
|
40
42
|
|
41
43
|
class Element
|
42
44
|
attr_accessor :value
|
45
|
+
|
43
46
|
def initialize(x)
|
44
47
|
@value = x
|
45
48
|
end
|
49
|
+
|
50
|
+
# stub this out because we're not actually
|
51
|
+
# using a real HTML page for these tests
|
52
|
+
def wait_until_present
|
53
|
+
self
|
54
|
+
end
|
46
55
|
end
|
47
56
|
|
48
57
|
class ProcessPageControllerView < Page
|
49
58
|
|
50
|
-
keyword(:a) {Element.new :a}
|
59
|
+
keyword(:a) { Element.new :a }
|
51
60
|
process_page('Page 1') do
|
52
|
-
keyword(:b) {Element.new :b}
|
61
|
+
keyword(:b) { Element.new :b }
|
53
62
|
end
|
54
63
|
process_page('Page 2') do
|
55
|
-
keyword(:c) {Element.new :c}
|
56
|
-
keyword(:d) {Element.new :d}
|
64
|
+
keyword(:c) { Element.new :c }
|
65
|
+
keyword(:d) { Element.new :d }
|
57
66
|
end
|
58
|
-
keyword(:e) {method :e}
|
67
|
+
keyword(:e) { method :e }
|
59
68
|
keyword(:radio_map,
|
60
|
-
|
61
|
-
|
62
|
-
)
|
69
|
+
['M'] => 'male',
|
70
|
+
[/f/i] => 'female'
|
71
|
+
) { Page.browser.radio(:name, 'sex') }
|
63
72
|
end
|
64
73
|
|
65
74
|
class TestProcessPageController < Watirmark::WebPage::Controller
|
@@ -80,27 +89,27 @@ describe Watirmark::WebPage::Controller do
|
|
80
89
|
Page.browser.refresh #reset page before each test
|
81
90
|
end
|
82
91
|
|
83
|
-
|
84
|
-
lambda{
|
92
|
+
specify 'should supportradio maps in controllers' do
|
93
|
+
lambda {
|
85
94
|
TestProcessPageController.new(:radio_map => 'f').populate_data
|
86
95
|
}.should_not raise_error
|
87
96
|
end
|
88
97
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
98
|
+
specify 'should be able to create and use a new keyword' do
|
99
|
+
view = TestView.new
|
100
|
+
view.send("#{@keyword}=", 'test')
|
101
|
+
expect(view.send(@keyword).value == 'test' ).to be_true
|
93
102
|
end
|
94
103
|
|
95
|
-
|
104
|
+
specify 'should be able to populate' do
|
96
105
|
module ControllerTest
|
97
106
|
class PopulateController < Watirmark::WebPage::Controller
|
98
107
|
@view = TestView
|
99
108
|
end
|
100
109
|
end
|
101
110
|
ControllerTest::PopulateController.new(
|
102
|
-
:text_field=>'test',
|
103
|
-
:select_list=>'b',
|
111
|
+
:text_field => 'test',
|
112
|
+
:select_list => 'b',
|
104
113
|
:another_text_field => 'nil'
|
105
114
|
).populate_data
|
106
115
|
v = TestView.new
|
@@ -109,11 +118,11 @@ describe Watirmark::WebPage::Controller do
|
|
109
118
|
v.another_text_field.value.should == ''
|
110
119
|
end
|
111
120
|
|
112
|
-
|
121
|
+
specify 'should be be able to interpret use value' do
|
113
122
|
@controller.value(@keyed_element).should == 'foobar'
|
114
123
|
end
|
115
124
|
|
116
|
-
|
125
|
+
specify 'should support override method to value' do
|
117
126
|
class TestController
|
118
127
|
def text_field_value
|
119
128
|
'override'
|
@@ -122,120 +131,133 @@ describe Watirmark::WebPage::Controller do
|
|
122
131
|
@controller.value(Watirmark::KeyedElement.new(TestController.new, :keyword => @keyword)).should == 'override'
|
123
132
|
end
|
124
133
|
|
125
|
-
|
126
|
-
def @controller.verify_text_field;
|
134
|
+
specify 'should support override method for verification' do
|
135
|
+
def @controller.verify_text_field;
|
136
|
+
'verify';
|
137
|
+
end
|
138
|
+
|
127
139
|
@controller.expects(:verify_text_field).returns('verify').once
|
128
140
|
@controller.verify_data
|
129
141
|
end
|
130
142
|
|
131
|
-
|
132
|
-
def @controller.before_text_field;
|
133
|
-
|
143
|
+
specify 'should support keyword before and after methods' do
|
144
|
+
def @controller.before_text_field;
|
145
|
+
'before';
|
146
|
+
end
|
147
|
+
|
148
|
+
def @controller.after_text_field;
|
149
|
+
'after';
|
150
|
+
end
|
151
|
+
|
134
152
|
@controller.expects(:before_text_field).returns('before').once
|
135
153
|
@controller.expects(:after_text_field).returns('after').once
|
136
154
|
@controller.populate_data {}
|
137
155
|
end
|
138
156
|
|
139
|
-
|
157
|
+
specify 'should propogate page declaration to subclasses' do
|
140
158
|
TestControllerSubclass.view.should == TestView
|
141
159
|
end
|
142
160
|
|
143
|
-
|
144
|
-
c = TestProcessPageController.new({:a=>1, :b=>1, :c=>1, :d=>1})
|
145
|
-
|
161
|
+
specify 'should support before methods for process pages' do
|
162
|
+
c = TestProcessPageController.new({:a => 1, :b => 1, :c => 1, :d => 1})
|
163
|
+
|
164
|
+
def c.before_process_page_page_1;
|
165
|
+
true;
|
166
|
+
end
|
167
|
+
|
146
168
|
c.expects(:before_process_page_page_1).returns('true').once
|
147
169
|
c.populate_data
|
148
170
|
end
|
149
171
|
|
150
|
-
|
172
|
+
specify 'should throw a Watirmark::VerificationException when a verification fails' do
|
151
173
|
lambda {
|
152
174
|
VerifyController.new(:validate1 => '2').verify_data
|
153
|
-
}.should raise_error(Watirmark::VerificationException,"validate1: expected '2' (String) got '1' (String)")
|
175
|
+
}.should raise_error(Watirmark::VerificationException, "validate1: expected '2' (String) got '1' (String)")
|
154
176
|
end
|
155
177
|
|
156
|
-
|
178
|
+
specify 'should not throw an exception when a verification succeeds' do
|
157
179
|
VerifyController.new(:validate2 => 'a').verify_data
|
158
180
|
end
|
159
181
|
|
160
|
-
|
161
|
-
VerifyController.new(:validate1 => '1'
|
182
|
+
specify 'should not throw an exception when many verifications succeed' do
|
183
|
+
VerifyController.new(:validate1 => '1', :validate2 => 'a', :validate3 => 1.1).verify_data
|
162
184
|
end
|
163
185
|
|
164
|
-
|
186
|
+
specify 'should only throw one validation exception when there are 3 three problems' do
|
165
187
|
lambda {
|
166
|
-
|
188
|
+
VerifyController.new(:validate1 => 'z', :validate2 => 'y', :validate3 => 'x').verify_data
|
167
189
|
}.should raise_error(Watirmark::VerificationException)
|
168
190
|
end
|
169
191
|
|
170
|
-
|
192
|
+
specify 'should throw an exception when verifying a verify_keyword fails' do
|
171
193
|
lambda {
|
172
194
|
VerifyController.new(:label1 => 'text').verify_data
|
173
|
-
}.should raise_error(Watirmark::VerificationException,"label1: expected 'text' (String) got 'numbers' (String)")
|
195
|
+
}.should raise_error(Watirmark::VerificationException, "label1: expected 'text' (String) got 'numbers' (String)")
|
174
196
|
end
|
175
197
|
|
176
|
-
|
198
|
+
specify 'should not throw an exception when verifying a verify_keyword succeeds' do
|
177
199
|
VerifyController.new(:label1 => 'numbers', :value1 => 1).verify_data
|
178
200
|
end
|
179
201
|
|
180
|
-
|
202
|
+
specify 'should not throw an exception when populating with a verify_keyword' do
|
181
203
|
VerifyController.new(:label1 => 'string').populate_data
|
182
204
|
end
|
183
205
|
|
184
|
-
|
206
|
+
specify 'should throw an exception when populating a populate_keyword fails' do
|
185
207
|
lambda {
|
186
208
|
VerifyController.new(:populate2 => '32').populate_data
|
187
209
|
}.should raise_error(NoMethodError)
|
188
210
|
end
|
189
211
|
|
190
|
-
|
212
|
+
specify 'should not throw an exception when populating a populate_keyword succeeds' do
|
191
213
|
VerifyController.new(:populate1 => '3.14159').populate_data
|
192
214
|
end
|
193
215
|
|
194
|
-
|
216
|
+
specify 'should not throw an exception when verifying with a populate_keyword' do
|
195
217
|
VerifyController.new(:populate1 => 'void').verify_data
|
196
218
|
end
|
197
219
|
|
198
|
-
|
220
|
+
specify 'should not populate a private_keyword successfully' do
|
199
221
|
c = VerifyController.new(:validate1 => 'hello')
|
200
222
|
c.populate_data
|
201
223
|
VerifyController.new(:private_validate1 => 'goodbye').populate_data
|
202
224
|
c.verify_data
|
203
225
|
end
|
204
226
|
|
205
|
-
|
227
|
+
specify 'should not verify a private_keyword successfully' do
|
206
228
|
c = VerifyController.new(:private_validate1 => 'hello')
|
207
229
|
VerifyController.new(:validate1 => 'goodbye').populate_data
|
208
230
|
c.verify_data
|
209
231
|
end
|
210
232
|
|
211
|
-
|
233
|
+
specify 'should not throw an exception when populating or verifying a private_keyword fails' do
|
212
234
|
c = VerifyController.new(:private_validate1 => 'goodbye')
|
213
235
|
c.populate_data
|
214
236
|
c.model.update(:private_validate1 => 'hello')
|
215
237
|
c.verify_data
|
216
238
|
end
|
217
239
|
|
218
|
-
|
240
|
+
specify 'should not throw an exception when populating or verifying a navigation_keyword fails' do
|
219
241
|
c = VerifyController.new(:button1 => 'Cancel')
|
220
242
|
c.populate_data
|
221
243
|
c.model.update(:button1 => 'Submit')
|
222
244
|
c.verify_data
|
223
245
|
end
|
224
246
|
|
225
|
-
|
247
|
+
specify 'false should be a valid keyword value' do
|
226
248
|
c = VerifyController.new(:checkbox => true)
|
227
249
|
c.populate_data
|
228
|
-
VerifyView.new.checkbox.set?.should
|
250
|
+
VerifyView.new.checkbox.set?.should == true
|
229
251
|
c.model.update(:checkbox => false)
|
230
252
|
c.populate_data
|
231
|
-
VerifyView.new.checkbox.set?.should
|
253
|
+
VerifyView.new.checkbox.set?.should == false
|
232
254
|
end
|
233
255
|
end
|
234
256
|
|
235
257
|
describe "controllers should be able to detect and use embedded models" do
|
236
258
|
before :all do
|
237
259
|
class MyView < Page
|
238
|
-
keyword(:element) {@@element}
|
260
|
+
keyword(:element) { @@element }
|
239
261
|
end
|
240
262
|
@controller = Class.new Watirmark::WebPage::Controller do
|
241
263
|
@view = MyView
|
@@ -254,19 +276,19 @@ describe "controllers should be able to detect and use embedded models" do
|
|
254
276
|
@password = Password.new
|
255
277
|
@login = Login.new
|
256
278
|
@login.add_model @password
|
257
|
-
@model = User.new(:first_name=> 'first')
|
279
|
+
@model = User.new(:first_name => 'first')
|
258
280
|
@model.add_model @login
|
259
281
|
end
|
260
282
|
|
261
|
-
|
283
|
+
specify 'should be able to see itself' do
|
262
284
|
@model.find(User).should == @model
|
263
285
|
end
|
264
286
|
|
265
|
-
|
287
|
+
specify 'should be able to see a sub_model' do
|
266
288
|
@model.find(Login).should == @login
|
267
289
|
end
|
268
290
|
|
269
|
-
|
291
|
+
specify 'should be able to see a nested sub_model' do
|
270
292
|
@model.find(Password).should == @password
|
271
293
|
end
|
272
294
|
end
|
@@ -285,7 +307,7 @@ describe "controllers should create a default model if one exists" do
|
|
285
307
|
end
|
286
308
|
end
|
287
309
|
|
288
|
-
|
310
|
+
specify 'should be able to see itself' do
|
289
311
|
c = @controller.new
|
290
312
|
c.model.should be_kind_of(MyModel)
|
291
313
|
end
|
@@ -297,9 +319,9 @@ describe "Similar Models" do
|
|
297
319
|
before :all do
|
298
320
|
class ProcessPageControllerView < Page
|
299
321
|
|
300
|
-
keyword(:a) {Element.new :a}
|
322
|
+
keyword(:a) { Element.new :a }
|
301
323
|
process_page('Page 1') do
|
302
|
-
keyword(:b) {Element.new :b}
|
324
|
+
keyword(:b) { Element.new :b }
|
303
325
|
end
|
304
326
|
process_page('Page 2') do
|
305
327
|
keyword(:c) { Element.new :c }
|
@@ -365,36 +387,34 @@ describe "Similar Models" do
|
|
365
387
|
class TestNoModelController < Watirmark::WebPage::Controller
|
366
388
|
@view = ProcessPageControllerView
|
367
389
|
end
|
368
|
-
|
369
|
-
|
370
390
|
end
|
371
391
|
|
372
|
-
|
392
|
+
specify 'should use the similar modelA' do
|
373
393
|
@controller = TestProcessPageController.new(ModelD.new)
|
374
394
|
@controller.model.should be_kind_of ModelB
|
375
395
|
@controller.supermodel.should be_kind_of ModelD
|
376
396
|
end
|
377
397
|
|
378
|
-
|
398
|
+
specify 'should use the top model' do
|
379
399
|
@controller = TestProcessPageController.new(ModelB.new)
|
380
400
|
@controller.model.should be_kind_of ModelB
|
381
401
|
@controller.supermodel.should be_kind_of ModelB
|
382
402
|
end
|
383
403
|
|
384
|
-
|
404
|
+
specify 'should use parent model' do
|
385
405
|
@controller = TestProcessPageController.new(ModelC.new)
|
386
406
|
@controller.model.should be_kind_of ModelA
|
387
407
|
@controller.supermodel.should be_kind_of ModelC
|
388
408
|
end
|
389
409
|
|
390
|
-
|
410
|
+
specify 'should call the smallest child similar to the model in controller' do
|
391
411
|
@controller = TestProcessPageController.new(ModelE.new)
|
392
412
|
@controller.model.should be_kind_of ModelB
|
393
413
|
@controller.supermodel.should be_kind_of ModelE
|
394
414
|
|
395
415
|
end
|
396
416
|
|
397
|
-
|
417
|
+
specify 'should select the correct model when base model has 2 similar models' do
|
398
418
|
@controller = TestProcessPageController.new(ModelG.new)
|
399
419
|
@controller.model.should be_kind_of ModelF
|
400
420
|
@controller.supermodel.should be_kind_of ModelG
|
@@ -404,19 +424,19 @@ describe "Similar Models" do
|
|
404
424
|
@controller.supermodel.should be_kind_of ModelF
|
405
425
|
end
|
406
426
|
|
407
|
-
|
427
|
+
specify 'should use the supermodel as a model if a controller model is not defined' do
|
408
428
|
@controller = TestNoModelController.new(ModelE.new)
|
409
429
|
@controller.model.should be_kind_of ModelE
|
410
430
|
@controller.supermodel.should be_kind_of ModelE
|
411
431
|
end
|
412
432
|
|
413
|
-
|
433
|
+
specify 'should use passed in model as @model when model_type is not defined' do
|
414
434
|
@controller = TestProcessPageController.new(ModelH.new)
|
415
435
|
@controller.model.should be_kind_of ModelH
|
416
436
|
@controller.supermodel.should be_kind_of ModelH
|
417
437
|
end
|
418
438
|
|
419
|
-
|
439
|
+
specify 'should allow us to override the default model' do
|
420
440
|
@controller = TestProcessPageController.new(ModelH.new)
|
421
441
|
@controller.model.should be_kind_of ModelH
|
422
442
|
@controller.model = ModelA.new
|