rsel 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/Rakefile +22 -8
- data/docs/development.md +1 -0
- data/docs/history.md +11 -1
- data/docs/index.md +1 -0
- data/docs/scoping.md +1 -1
- data/docs/studying.md +76 -0
- data/lib/rsel/selenium_test.rb +505 -90
- data/lib/rsel/study_html.rb +198 -0
- data/lib/rsel/support.rb +105 -4
- data/rsel.gemspec +1 -1
- data/spec/spec_helper.rb +4 -22
- data/spec/st_alerts.rb +48 -0
- data/spec/st_browser_spec.rb +58 -0
- data/spec/st_buttons_spec.rb +95 -0
- data/spec/st_checkboxes_spec.rb +235 -0
- data/spec/st_conditionals_spec.rb +180 -0
- data/spec/st_dropdowns_spec.rb +140 -0
- data/spec/st_field_equals_among_spec.rb +48 -0
- data/spec/st_fields_equal_among_spec.rb +74 -0
- data/spec/st_fields_equal_spec.rb +90 -0
- data/spec/st_fields_spec.rb +167 -0
- data/spec/st_initialization_spec.rb +33 -0
- data/spec/st_links_spec.rb +84 -0
- data/spec/st_method_missing_spec.rb +59 -0
- data/spec/st_navigation_spec.rb +56 -0
- data/spec/st_radiobuttons_spec.rb +123 -0
- data/spec/st_respond_to_spec.rb +16 -0
- data/spec/st_scenario_spec.rb +26 -0
- data/spec/st_set_field_among_spec.rb +45 -0
- data/spec/st_set_field_spec.rb +842 -0
- data/spec/st_set_fields_among_spec.rb +74 -0
- data/spec/st_set_fields_spec.rb +97 -0
- data/spec/st_spec_helper.rb +43 -0
- data/spec/st_stop_on_failure_spec.rb +199 -0
- data/spec/st_tables_spec.rb +42 -0
- data/spec/st_temporal_visibility_spec.rb +122 -0
- data/spec/st_visibility_spec.rb +125 -0
- data/spec/st_waiting_spec.rb +37 -0
- data/spec/study_html_spec.rb +310 -0
- data/spec/support_spec.rb +163 -13
- data/test/server/README.txt +3 -0
- data/test/views/alert.erb +15 -0
- data/test/views/form.erb +6 -1
- data/test/views/index.erb +2 -0
- data/test/views/slowtext.erb +1 -1
- metadata +38 -9
- data/spec/selenium_test_spec.rb +0 -2656
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec/st_spec_helper'
|
2
|
+
|
3
|
+
describe 'browser window' do
|
4
|
+
describe "#open_browser" do
|
5
|
+
it "raises StopTestCannotConnect if the connection fails" do
|
6
|
+
st = Rsel::SeleniumTest.new('bogus_host')
|
7
|
+
lambda do
|
8
|
+
st.open_browser
|
9
|
+
end.should raise_error(Rsel::StopTestCannotConnect)
|
10
|
+
end
|
11
|
+
|
12
|
+
# TODO: Find a cross-platform way of testing this
|
13
|
+
#it "uses the javascript-xpath library for *iexplore" do
|
14
|
+
#st = Rsel::SeleniumTest.new('localhost', :browser => '*iexplore')
|
15
|
+
#st.open_browser
|
16
|
+
#end
|
17
|
+
|
18
|
+
it "reports failure to connect to a bogus Selenium server" do
|
19
|
+
st = Rsel::SeleniumTest.new('http://localhost:8070', { :host => 'localhost', :port => '8070' })
|
20
|
+
lambda do
|
21
|
+
st.open_browser
|
22
|
+
end.should raise_error(Rsel::StopTestCannotConnect)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#maximize_browser" do
|
28
|
+
it "returns true" do
|
29
|
+
st = Rsel::SeleniumTest.new('http://localhost:8070')
|
30
|
+
st.open_browser
|
31
|
+
st.maximize_browser.should be_true
|
32
|
+
st.close_browser
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#close_browser" do
|
37
|
+
before(:each) do
|
38
|
+
@st_temp = Rsel::SeleniumTest.new('http://localhost:8070/')
|
39
|
+
@st_temp.open_browser
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns true if there are no errors" do
|
43
|
+
@st_temp.close_browser('and show errors').should be_true
|
44
|
+
end
|
45
|
+
|
46
|
+
it "returns true if there are errors, but show_errors is unset" do
|
47
|
+
@st_temp.field_equals("Nonexistent field", "Nonexistent words")
|
48
|
+
@st_temp.close_browser('without showing errors').should be_true
|
49
|
+
end
|
50
|
+
|
51
|
+
it "raises StopTestStepFailed if there are errors and show_errors is set" do
|
52
|
+
@st_temp.field_equals("Nonexistent field", "Nonexistent words")
|
53
|
+
lambda do
|
54
|
+
@st_temp.close_browser('and show errors')
|
55
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'spec/st_spec_helper'
|
2
|
+
|
3
|
+
describe 'buttons' do
|
4
|
+
before(:each) do
|
5
|
+
@st.visit("/form").should be_true
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#click_button" do
|
9
|
+
context "passes when" do
|
10
|
+
context "studying and " do
|
11
|
+
it "button exists and is enabled" do
|
12
|
+
@st.begin_study
|
13
|
+
@st.click_button("Submit person form").should be_true
|
14
|
+
@st.end_study
|
15
|
+
end
|
16
|
+
|
17
|
+
it "button exists within scope" do
|
18
|
+
@st.begin_study
|
19
|
+
@st.click_button("Submit person form", :within => "person_form").should be_true
|
20
|
+
@st.end_study
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "button exists and is enabled" do
|
25
|
+
@st.click_button("Submit person form").should be_true
|
26
|
+
end
|
27
|
+
|
28
|
+
it "button exists within scope" do
|
29
|
+
@st.click_button("Submit person form", :within => "person_form").should be_true
|
30
|
+
end
|
31
|
+
|
32
|
+
it "button exists in table row" do
|
33
|
+
# TODO
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "fails when" do
|
38
|
+
it "button does not exist" do
|
39
|
+
@st.click_button("No such button").should be_false
|
40
|
+
end
|
41
|
+
|
42
|
+
it "button exists, but not within scope" do
|
43
|
+
@st.click_button("Submit person form", :within => "spouse_form").should be_false
|
44
|
+
end
|
45
|
+
|
46
|
+
it "button exists, but not in table row" do
|
47
|
+
# TODO
|
48
|
+
end
|
49
|
+
|
50
|
+
it "button exists, but is read-only" do
|
51
|
+
@st.visit("/readonly_form").should be_true
|
52
|
+
@st.click_button("Submit person form").should be_false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
describe "#button_exists" do
|
59
|
+
context "passes when" do
|
60
|
+
context "button with text" do
|
61
|
+
it "exists" do
|
62
|
+
@st.button_exists("Submit person form").should be_true
|
63
|
+
@st.button_exists("Save preferences").should be_true
|
64
|
+
end
|
65
|
+
|
66
|
+
it "exists within scope" do
|
67
|
+
@st.button_exists("Submit person form", :within => "person_form").should be_true
|
68
|
+
@st.button_exists("Submit spouse form", :within => "spouse_form").should be_true
|
69
|
+
end
|
70
|
+
|
71
|
+
it "exists in table row" do
|
72
|
+
# TODO
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context "fails when" do
|
78
|
+
it "no such button exists" do
|
79
|
+
@st.button_exists("Apple").should be_false
|
80
|
+
@st.button_exists("Big Red").should be_false
|
81
|
+
end
|
82
|
+
|
83
|
+
it "button exists, but not within scope" do
|
84
|
+
@st.button_exists("Submit spouse form", :within => "person_form").should be_false
|
85
|
+
@st.button_exists("Submit person form", :within => "spouse_form").should be_false
|
86
|
+
end
|
87
|
+
|
88
|
+
it "button exists, but not in table row" do
|
89
|
+
# TODO
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
@@ -0,0 +1,235 @@
|
|
1
|
+
require 'spec/st_spec_helper'
|
2
|
+
|
3
|
+
describe 'checkboxes' do
|
4
|
+
before(:each) do
|
5
|
+
@st.visit("/form").should be_true
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#enable_checkbox" do
|
9
|
+
context "passes when" do
|
10
|
+
context "checkbox with label" do
|
11
|
+
it "exists" do
|
12
|
+
@st.enable_checkbox("I like cheese").should be_true
|
13
|
+
@st.enable_checkbox("I like salami").should be_true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "exists and is already checked" do
|
17
|
+
@st.enable_checkbox("I like cheese")
|
18
|
+
@st.enable_checkbox("I like cheese").should be_true
|
19
|
+
end
|
20
|
+
|
21
|
+
it "exists within scope" do
|
22
|
+
@st.enable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
23
|
+
@st.enable_checkbox("I like salami", :within => "salami_checkbox").should be_true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "exists in table row" do
|
27
|
+
@st.visit("/table")
|
28
|
+
@st.enable_checkbox("Like", :in_row => "Marcus").should be_true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "checkbox with id=" do
|
33
|
+
it "exists" do
|
34
|
+
@st.enable_checkbox("id=like_cheese").should be_true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "checkbox with xpath=" do
|
39
|
+
it "exists" do
|
40
|
+
@st.enable_checkbox("xpath=//input[@id='like_cheese']").should be_true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "fails when" do
|
46
|
+
context "checkbox with label" do
|
47
|
+
it "does not exist" do
|
48
|
+
@st.enable_checkbox("I dislike bacon").should be_false
|
49
|
+
@st.enable_checkbox("I like broccoli").should be_false
|
50
|
+
end
|
51
|
+
|
52
|
+
it "exists, but not within scope" do
|
53
|
+
@st.enable_checkbox("I like cheese", :within => "salami_checkbox").should be_false
|
54
|
+
@st.enable_checkbox("I like salami", :within => "cheese_checkbox").should be_false
|
55
|
+
end
|
56
|
+
|
57
|
+
it "exists, but not in table row" do
|
58
|
+
@st.visit("/table")
|
59
|
+
@st.enable_checkbox("Like", :in_row => "Eric").should be_false
|
60
|
+
end
|
61
|
+
|
62
|
+
it "exists, but is read-only" do
|
63
|
+
@st.visit("/readonly_form").should be_true
|
64
|
+
@st.enable_checkbox("I like salami").should be_false
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#disable_checkbox" do
|
71
|
+
context "passes when" do
|
72
|
+
context "checkbox with label" do
|
73
|
+
it "exists" do
|
74
|
+
@st.disable_checkbox("I like cheese").should be_true
|
75
|
+
@st.disable_checkbox("I like salami").should be_true
|
76
|
+
end
|
77
|
+
|
78
|
+
it "exists and is already unchecked" do
|
79
|
+
@st.disable_checkbox("I like cheese")
|
80
|
+
@st.disable_checkbox("I like cheese").should be_true
|
81
|
+
end
|
82
|
+
|
83
|
+
it "exists within scope" do
|
84
|
+
@st.disable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
85
|
+
@st.disable_checkbox("I like salami", :within => "preferences_form").should be_true
|
86
|
+
end
|
87
|
+
|
88
|
+
it "exists in table row" do
|
89
|
+
@st.visit("/table")
|
90
|
+
@st.disable_checkbox("Like", :in_row => "Marcus").should be_true
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context "checkbox with id=" do
|
95
|
+
it "exists" do
|
96
|
+
@st.disable_checkbox("id=like_cheese").should be_true
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "checkbox with xpath=" do
|
101
|
+
it "exists" do
|
102
|
+
@st.disable_checkbox("xpath=//input[@id='like_cheese']").should be_true
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context "fails when" do
|
108
|
+
context "checkbox with label" do
|
109
|
+
it "does not exist" do
|
110
|
+
@st.disable_checkbox("I dislike bacon").should be_false
|
111
|
+
@st.disable_checkbox("I like broccoli").should be_false
|
112
|
+
end
|
113
|
+
|
114
|
+
it "exists, but not within scope" do
|
115
|
+
@st.disable_checkbox("I like cheese", :within => "salami_checkbox").should be_false
|
116
|
+
@st.disable_checkbox("I like salami", :within => "cheese_checkbox").should be_false
|
117
|
+
end
|
118
|
+
|
119
|
+
it "exists, but not in table row" do
|
120
|
+
@st.visit("/table")
|
121
|
+
@st.disable_checkbox("Like", :in_row => "Eric").should be_false
|
122
|
+
end
|
123
|
+
|
124
|
+
it "exists, but is read-only" do
|
125
|
+
@st.visit("/readonly_form").should be_true
|
126
|
+
@st.disable_checkbox("I like cheese").should be_false
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "#checkbox_is_enabled" do
|
133
|
+
context "passes when" do
|
134
|
+
context "checkbox with label" do
|
135
|
+
it "exists and is checked" do
|
136
|
+
@st.enable_checkbox("I like cheese").should be_true
|
137
|
+
@st.checkbox_is_enabled("I like cheese").should be_true
|
138
|
+
end
|
139
|
+
|
140
|
+
it "exists within scope and is checked" do
|
141
|
+
@st.enable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
142
|
+
@st.checkbox_is_enabled("I like cheese", :within => "cheese_checkbox").should be_true
|
143
|
+
end
|
144
|
+
|
145
|
+
it "exists in table row and is checked" do
|
146
|
+
@st.visit("/table")
|
147
|
+
@st.enable_checkbox("Like", :in_row => "Ken").should be_true
|
148
|
+
@st.checkbox_is_enabled("Like", :in_row => "Ken").should be_true
|
149
|
+
end
|
150
|
+
|
151
|
+
it "exists and is checked, but read-only" do
|
152
|
+
@st.visit("/readonly_form").should be_true
|
153
|
+
@st.checkbox_is_enabled("I like cheese").should be_true
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
context "fails when" do
|
159
|
+
context "checkbox with label" do
|
160
|
+
it "does not exist" do
|
161
|
+
@st.checkbox_is_enabled("I dislike bacon").should be_false
|
162
|
+
end
|
163
|
+
|
164
|
+
it "exists but is unchecked" do
|
165
|
+
@st.disable_checkbox("I like cheese").should be_true
|
166
|
+
@st.checkbox_is_enabled("I like cheese").should be_false
|
167
|
+
end
|
168
|
+
|
169
|
+
it "exists and is checked, but not within scope" do
|
170
|
+
@st.enable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
171
|
+
@st.checkbox_is_enabled("I like cheese", :within => "salami_checkbox").should be_false
|
172
|
+
end
|
173
|
+
|
174
|
+
it "exists and is checked, but not in table row" do
|
175
|
+
@st.visit("/table")
|
176
|
+
@st.enable_checkbox("Like", :in_row => "Marcus").should be_true
|
177
|
+
@st.checkbox_is_enabled("Like", :in_row => "Eric").should be_false
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe "#checkbox_is_disabled" do
|
184
|
+
context "passes when" do
|
185
|
+
context "checkbox with label" do
|
186
|
+
it "exists and is unchecked" do
|
187
|
+
@st.disable_checkbox("I like cheese").should be_true
|
188
|
+
@st.checkbox_is_disabled("I like cheese").should be_true
|
189
|
+
end
|
190
|
+
|
191
|
+
it "exists within scope and is unchecked" do
|
192
|
+
@st.disable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
193
|
+
@st.checkbox_is_disabled("I like cheese", :within => "cheese_checkbox").should be_true
|
194
|
+
end
|
195
|
+
|
196
|
+
it "exists in table row and is unchecked" do
|
197
|
+
@st.visit("/table")
|
198
|
+
@st.disable_checkbox("Like", :in_row => "Ken").should be_true
|
199
|
+
@st.checkbox_is_disabled("Like", :in_row => "Ken").should be_true
|
200
|
+
end
|
201
|
+
|
202
|
+
it "exists and is unchecked, but read-only" do
|
203
|
+
@st.visit("/readonly_form").should be_true
|
204
|
+
@st.checkbox_is_disabled("I like salami").should be_true
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
context "fails when" do
|
210
|
+
context "checkbox with label" do
|
211
|
+
it "does not exist" do
|
212
|
+
@st.checkbox_is_disabled("I dislike bacon").should be_false
|
213
|
+
end
|
214
|
+
|
215
|
+
it "exists but is checked" do
|
216
|
+
@st.enable_checkbox("I like cheese").should be_true
|
217
|
+
@st.checkbox_is_disabled("I like cheese").should be_false
|
218
|
+
end
|
219
|
+
|
220
|
+
it "exists and is unchecked, but not within scope" do
|
221
|
+
@st.disable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
222
|
+
@st.checkbox_is_disabled("I like cheese", :within => "salami_checkbox").should be_false
|
223
|
+
end
|
224
|
+
|
225
|
+
it "exists and is unchecked, but not in table row" do
|
226
|
+
@st.visit("/table")
|
227
|
+
@st.disable_checkbox("Like", :in_row => "Marcus").should be_true
|
228
|
+
@st.checkbox_is_disabled("Like", :in_row => "Eric").should be_false
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
|
@@ -0,0 +1,180 @@
|
|
1
|
+
require 'spec/st_spec_helper'
|
2
|
+
|
3
|
+
describe 'conditionals' do
|
4
|
+
before(:each) do
|
5
|
+
@st.visit("/").should be_true
|
6
|
+
@st.reset_conditionals
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#if_i_see" do
|
10
|
+
context "passes when" do
|
11
|
+
it "sees text" do
|
12
|
+
@st.if_i_see("About this site").should be_true
|
13
|
+
@st.click("About this site").should be_true
|
14
|
+
@st.end_if.should be_true
|
15
|
+
end
|
16
|
+
|
17
|
+
it "is inside a passed block" do
|
18
|
+
@st.if_i_see("About this site").should be_true
|
19
|
+
@st.click("About this site").should be_true
|
20
|
+
@st.page_loads_in_seconds_or_less(10).should be_true
|
21
|
+
@st.if_i_see("This site is").should be_true
|
22
|
+
@st.see("is really cool.").should be_true
|
23
|
+
@st.end_if.should be_true
|
24
|
+
@st.end_if.should be_true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "skips when" do
|
29
|
+
it "does not see text" do
|
30
|
+
@st.if_i_see("Bogus link").should be_nil
|
31
|
+
@st.click("Bogus link").should be_nil
|
32
|
+
@st.end_if.should be_true
|
33
|
+
end
|
34
|
+
|
35
|
+
it "is inside a skipped block" do
|
36
|
+
@st.if_i_see("Bogus link").should be_nil
|
37
|
+
@st.click("Bogus link").should be_nil
|
38
|
+
@st.if_i_see("About this site").should be_nil
|
39
|
+
@st.click("About this site").should be_nil
|
40
|
+
@st.end_if.should be_nil
|
41
|
+
@st.end_if.should be_true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#if_parameter" do
|
47
|
+
context "passes when" do
|
48
|
+
it "sees yes" do
|
49
|
+
@st.if_parameter("yes").should be_true
|
50
|
+
@st.click("About this site").should be_true
|
51
|
+
@st.end_if.should be_true
|
52
|
+
end
|
53
|
+
|
54
|
+
it "sees true" do
|
55
|
+
@st.if_parameter("true").should be_true
|
56
|
+
@st.click("About this site").should be_true
|
57
|
+
@st.end_if.should be_true
|
58
|
+
end
|
59
|
+
|
60
|
+
it "sees YES" do
|
61
|
+
@st.if_parameter("YES").should be_true
|
62
|
+
@st.click("About this site").should be_true
|
63
|
+
@st.end_if.should be_true
|
64
|
+
end
|
65
|
+
|
66
|
+
it "sees TRUE" do
|
67
|
+
@st.if_parameter("TRUE").should be_true
|
68
|
+
@st.click("About this site").should be_true
|
69
|
+
@st.end_if.should be_true
|
70
|
+
end
|
71
|
+
|
72
|
+
it "is inside a passed block" do
|
73
|
+
@st.if_i_see("About this site").should be_true
|
74
|
+
@st.click("About this site").should be_true
|
75
|
+
@st.page_loads_in_seconds_or_less(10).should be_true
|
76
|
+
@st.if_parameter("True").should be_true
|
77
|
+
@st.see("is really cool.").should be_true
|
78
|
+
@st.end_if.should be_true
|
79
|
+
@st.end_if.should be_true
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "skips when" do
|
84
|
+
it "sees something other than yes or true" do
|
85
|
+
@st.if_parameter("Bogus").should be_nil
|
86
|
+
@st.click("Bogus link").should be_nil
|
87
|
+
@st.end_if.should be_true
|
88
|
+
end
|
89
|
+
|
90
|
+
it "is inside a skipped block" do
|
91
|
+
@st.if_parameter("Bogus link").should be_nil
|
92
|
+
@st.click("Bogus link").should be_nil
|
93
|
+
@st.if_parameter("TRUE").should be_nil
|
94
|
+
@st.click("About this site").should be_nil
|
95
|
+
@st.end_if.should be_nil
|
96
|
+
@st.end_if.should be_true
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# TODO: if_is
|
102
|
+
describe "#if_is" do
|
103
|
+
context "passes when" do
|
104
|
+
it "sees the same string" do
|
105
|
+
@st.if_is("yes", 'yes').should be_true
|
106
|
+
@st.click("About this site").should be_true
|
107
|
+
@st.end_if.should be_true
|
108
|
+
end
|
109
|
+
|
110
|
+
it "sees a matching empty string" do
|
111
|
+
@st.if_is("",'').should be_true
|
112
|
+
@st.click("About this site").should be_true
|
113
|
+
@st.end_if.should be_true
|
114
|
+
end
|
115
|
+
|
116
|
+
it "is inside a passed block" do
|
117
|
+
@st.if_i_see("About this site").should be_true
|
118
|
+
@st.click("About this site").should be_true
|
119
|
+
@st.page_loads_in_seconds_or_less(10).should be_true
|
120
|
+
@st.if_is("True", "True").should be_true
|
121
|
+
@st.see("is really cool.").should be_true
|
122
|
+
@st.end_if.should be_true
|
123
|
+
@st.end_if.should be_true
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
context "skips when" do
|
128
|
+
it "sees different strings" do
|
129
|
+
@st.if_is("Ken", "Bogus").should be_nil
|
130
|
+
@st.click("Bogus link").should be_nil
|
131
|
+
@st.end_if.should be_true
|
132
|
+
end
|
133
|
+
|
134
|
+
it "is inside a skipped block" do
|
135
|
+
@st.if_is("Ken", "Bogus").should be_nil
|
136
|
+
@st.click("Bogus link").should be_nil
|
137
|
+
@st.if_is("True", "True").should be_nil
|
138
|
+
@st.click("About this site").should be_nil
|
139
|
+
@st.end_if.should be_nil
|
140
|
+
@st.end_if.should be_true
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe "#otherwise" do
|
146
|
+
context "skips when" do
|
147
|
+
it "its if was true" do
|
148
|
+
@st.if_i_see("About this site").should be_true
|
149
|
+
@st.click("About this site").should be_true
|
150
|
+
@st.otherwise.should be_nil
|
151
|
+
@st.click("Bogus link").should be_nil
|
152
|
+
@st.end_if.should be_true
|
153
|
+
end
|
154
|
+
end
|
155
|
+
context "passes when" do
|
156
|
+
it "its if was false" do
|
157
|
+
@st.if_i_see("Bogus link").should be_nil
|
158
|
+
@st.click("Bogus link").should be_nil
|
159
|
+
@st.otherwise.should be_true
|
160
|
+
@st.click("About this site").should be_true
|
161
|
+
@st.end_if.should be_true
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
context "fails when" do
|
166
|
+
it "does not have a matching if" do
|
167
|
+
@st.otherwise.should be_false
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe "#end_if" do
|
173
|
+
context "fails when" do
|
174
|
+
it "does not have a matching if" do
|
175
|
+
@st.end_if.should be_false
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|