capybara_minitest_spec 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/.gitignore +4 -0
- data/.gitmodules +3 -0
- data/.rvmrc +1 -0
- data/Gemfile +7 -0
- data/README.md +31 -0
- data/Rakefile +9 -0
- data/capybara_minitest_spec.gemspec +25 -0
- data/lib/capybara_minitest_spec/version.rb +3 -0
- data/lib/capybara_minitest_spec.rb +45 -0
- data/test/matchers_spec.rb +447 -0
- data/test/spec_helper.rb +28 -0
- data/test_app/driver.rb +297 -0
- data/test_app/fixtures/capybara.jpg +3 -0
- data/test_app/fixtures/test_file.txt +1 -0
- data/test_app/public/test.js +43 -0
- data/test_app/session/all_spec.rb +78 -0
- data/test_app/session/attach_file_spec.rb +73 -0
- data/test_app/session/check_spec.rb +65 -0
- data/test_app/session/choose_spec.rb +26 -0
- data/test_app/session/click_button_spec.rb +304 -0
- data/test_app/session/click_link_or_button_spec.rb +36 -0
- data/test_app/session/click_link_spec.rb +119 -0
- data/test_app/session/current_host_spec.rb +68 -0
- data/test_app/session/current_url_spec.rb +15 -0
- data/test_app/session/fill_in_spec.rb +125 -0
- data/test_app/session/find_button_spec.rb +18 -0
- data/test_app/session/find_by_id_spec.rb +18 -0
- data/test_app/session/find_field_spec.rb +26 -0
- data/test_app/session/find_link_spec.rb +19 -0
- data/test_app/session/find_spec.rb +149 -0
- data/test_app/session/first_spec.rb +105 -0
- data/test_app/session/has_button_spec.rb +32 -0
- data/test_app/session/has_content_spec.rb +106 -0
- data/test_app/session/has_css_spec.rb +243 -0
- data/test_app/session/has_field_spec.rb +192 -0
- data/test_app/session/has_link_spec.rb +37 -0
- data/test_app/session/has_select_spec.rb +129 -0
- data/test_app/session/has_selector_spec.rb +129 -0
- data/test_app/session/has_table_spec.rb +96 -0
- data/test_app/session/has_xpath_spec.rb +123 -0
- data/test_app/session/headers.rb +19 -0
- data/test_app/session/javascript.rb +289 -0
- data/test_app/session/response_code.rb +19 -0
- data/test_app/session/select_spec.rb +113 -0
- data/test_app/session/text_spec.rb +19 -0
- data/test_app/session/uncheck_spec.rb +21 -0
- data/test_app/session/unselect_spec.rb +61 -0
- data/test_app/session/within_spec.rb +178 -0
- data/test_app/session.rb +154 -0
- data/test_app/test_app.rb +142 -0
- data/test_app/views/buttons.erb +4 -0
- data/test_app/views/fieldsets.erb +29 -0
- data/test_app/views/form.erb +365 -0
- data/test_app/views/frame_one.erb +8 -0
- data/test_app/views/frame_two.erb +8 -0
- data/test_app/views/header_links.erb +7 -0
- data/test_app/views/host_links.erb +12 -0
- data/test_app/views/popup_one.erb +8 -0
- data/test_app/views/popup_two.erb +8 -0
- data/test_app/views/postback.erb +13 -0
- data/test_app/views/tables.erb +122 -0
- data/test_app/views/with_html.erb +74 -0
- data/test_app/views/with_html_entities.erb +1 -0
- data/test_app/views/with_js.erb +48 -0
- data/test_app/views/with_scope.erb +36 -0
- data/test_app/views/with_simple_html.erb +1 -0
- data/test_app/views/within_frames.erb +10 -0
- data/test_app/views/within_popups.erb +25 -0
- metadata +158 -0
@@ -0,0 +1,243 @@
|
|
1
|
+
shared_examples_for "has_css" do
|
2
|
+
describe '#has_css?' do
|
3
|
+
before do
|
4
|
+
@session.visit('/with_html')
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should be true if the given selector is on the page" do
|
8
|
+
@session.should have_css("p")
|
9
|
+
@session.should have_css("p a#foo")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should be false if the given selector is not on the page" do
|
13
|
+
@session.should_not have_css("abbr")
|
14
|
+
@session.should_not have_css("p a#doesnotexist")
|
15
|
+
@session.should_not have_css("p.nosuchclass")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should respect scopes" do
|
19
|
+
@session.within "//p[@id='first']" do
|
20
|
+
@session.should have_css("a#foo")
|
21
|
+
@session.should_not have_css("a#red")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "with between" do
|
26
|
+
it "should be true if the content occurs within the range given" do
|
27
|
+
@session.should have_css("p", :between => 1..4)
|
28
|
+
@session.should have_css("p a#foo", :between => 1..3)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should be false if the content occurs more or fewer times than range" do
|
32
|
+
@session.should_not have_css("p", :between => 6..11 )
|
33
|
+
@session.should_not have_css("p a#foo", :between => 4..7)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should be false if the content isn't on the page at all" do
|
37
|
+
@session.should_not have_css("abbr", :between => 1..8)
|
38
|
+
@session.should_not have_css("p a.doesnotexist", :between => 3..8)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "with count" do
|
43
|
+
it "should be true if the content is on the page the given number of times" do
|
44
|
+
@session.should have_css("p", :count => 3)
|
45
|
+
@session.should have_css("p a#foo", :count => 1)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should be false if the content occurs the given number of times" do
|
49
|
+
@session.should_not have_css("p", :count => 6)
|
50
|
+
@session.should_not have_css("p a#foo", :count => 2)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should be false if the content isn't on the page at all" do
|
54
|
+
@session.should_not have_css("abbr", :count => 2)
|
55
|
+
@session.should_not have_css("p a.doesnotexist", :count => 1)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should coerce count to an integer" do
|
59
|
+
@session.should have_css("p", :count => "3")
|
60
|
+
@session.should have_css("p a#foo", :count => "1")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "with maximum" do
|
65
|
+
it "should be true when content occurs same or fewer times than given" do
|
66
|
+
@session.should have_css("h2.head", :maximum => 5) # edge case
|
67
|
+
@session.should have_css("h2", :maximum => 10)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should be false when content occurs more times than given" do
|
71
|
+
@session.should_not have_css("h2.head", :maximum => 4) # edge case
|
72
|
+
@session.should_not have_css("h2", :maximum => 6)
|
73
|
+
@session.should_not have_css("p", :maximum => 1)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should be false if the content isn't on the page at all" do
|
77
|
+
@session.should_not have_css("abbr", :maximum => 2)
|
78
|
+
@session.should_not have_css("p a.doesnotexist", :maximum => 1)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should coerce maximum to an integer" do
|
82
|
+
@session.should have_css("h2.head", :maximum => "5") # edge case
|
83
|
+
@session.should have_css("h2", :maximum => "10")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context "with minimum" do
|
88
|
+
it "should be true when content occurs same or more times than given" do
|
89
|
+
@session.should have_css("h2.head", :minimum => 5) # edge case
|
90
|
+
@session.should have_css("h2", :minimum => 3)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should be false when content occurs fewer times than given" do
|
94
|
+
@session.should_not have_css("h2.head", :minimum => 6) # edge case
|
95
|
+
@session.should_not have_css("h2", :minimum => 8)
|
96
|
+
@session.should_not have_css("p", :minimum => 10)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should be false if the content isn't on the page at all" do
|
100
|
+
@session.should_not have_css("abbr", :minimum => 2)
|
101
|
+
@session.should_not have_css("p a.doesnotexist", :minimum => 7)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should coerce minimum to an integer" do
|
105
|
+
@session.should have_css("h2.head", :minimum => "5") # edge case
|
106
|
+
@session.should have_css("h2", :minimum => "3")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context "with text" do
|
111
|
+
it "should discard all matches where the given string is not contained" do
|
112
|
+
@session.should have_css("p a", :text => "Redirect", :count => 1)
|
113
|
+
@session.should_not have_css("p a", :text => "Doesnotexist")
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should discard all matches where the given regexp is not matched" do
|
117
|
+
@session.should have_css("p a", :text => /re[dab]i/i, :count => 1)
|
118
|
+
@session.should_not have_css("p a", :text => /Red$/)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe '#has_no_css?' do
|
124
|
+
before do
|
125
|
+
@session.visit('/with_html')
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should be false if the given selector is on the page" do
|
129
|
+
@session.should_not have_no_css("p")
|
130
|
+
@session.should_not have_no_css("p a#foo")
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should be true if the given selector is not on the page" do
|
134
|
+
@session.should have_no_css("abbr")
|
135
|
+
@session.should have_no_css("p a#doesnotexist")
|
136
|
+
@session.should have_no_css("p.nosuchclass")
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should respect scopes" do
|
140
|
+
@session.within "//p[@id='first']" do
|
141
|
+
@session.should_not have_no_css("a#foo")
|
142
|
+
@session.should have_no_css("a#red")
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
context "with between" do
|
147
|
+
it "should be false if the content occurs within the range given" do
|
148
|
+
@session.should_not have_no_css("p", :between => 1..4)
|
149
|
+
@session.should_not have_no_css("p a#foo", :between => 1..3)
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should be true if the content occurs more or fewer times than range" do
|
153
|
+
@session.should have_no_css("p", :between => 6..11 )
|
154
|
+
@session.should have_no_css("p a#foo", :between => 4..7)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should be true if the content isn't on the page at all" do
|
158
|
+
@session.should have_no_css("abbr", :between => 1..8)
|
159
|
+
@session.should have_no_css("p a.doesnotexist", :between => 3..8)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
context "with count" do
|
164
|
+
it "should be false if the content is on the page the given number of times" do
|
165
|
+
@session.should_not have_no_css("p", :count => 3)
|
166
|
+
@session.should_not have_no_css("p a#foo", :count => 1)
|
167
|
+
end
|
168
|
+
|
169
|
+
it "should be true if the content is on the page the given number of times" do
|
170
|
+
@session.should have_no_css("p", :count => 6)
|
171
|
+
@session.should have_no_css("p a#foo", :count => 2)
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should be true if the content isn't on the page at all" do
|
175
|
+
@session.should have_no_css("abbr", :count => 2)
|
176
|
+
@session.should have_no_css("p a.doesnotexist", :count => 1)
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should coerce count to an integer" do
|
180
|
+
@session.should_not have_no_css("p", :count => "3")
|
181
|
+
@session.should_not have_no_css("p a#foo", :count => "1")
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
context "with maximum" do
|
186
|
+
it "should be false when content occurs same or fewer times than given" do
|
187
|
+
@session.should_not have_no_css("h2.head", :maximum => 5) # edge case
|
188
|
+
@session.should_not have_no_css("h2", :maximum => 10)
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should be true when content occurs more times than given" do
|
192
|
+
@session.should have_no_css("h2.head", :maximum => 4) # edge case
|
193
|
+
@session.should have_no_css("h2", :maximum => 6)
|
194
|
+
@session.should have_no_css("p", :maximum => 1)
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should be true if the content isn't on the page at all" do
|
198
|
+
@session.should have_no_css("abbr", :maximum => 5)
|
199
|
+
@session.should have_no_css("p a.doesnotexist", :maximum => 10)
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should coerce maximum to an integer" do
|
203
|
+
@session.should_not have_no_css("h2.head", :maximum => "5") # edge case
|
204
|
+
@session.should_not have_no_css("h2", :maximum => "10")
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
context "with minimum" do
|
209
|
+
it "should be false when content occurs more times than given" do
|
210
|
+
@session.should_not have_no_css("h2.head", :minimum => 4) # edge case
|
211
|
+
@session.should_not have_no_css("h2", :minimum => 3)
|
212
|
+
end
|
213
|
+
|
214
|
+
it "should be true when content occurs fewer times than given" do
|
215
|
+
@session.should have_no_css("h2.head", :minimum => 6) # edge case
|
216
|
+
@session.should have_no_css("h2", :minimum => 8)
|
217
|
+
@session.should have_no_css("p", :minimum => 15)
|
218
|
+
end
|
219
|
+
|
220
|
+
it "should be true if the content isn't on the page at all" do
|
221
|
+
@session.should have_no_css("abbr", :minimum => 5)
|
222
|
+
@session.should have_no_css("p a.doesnotexist", :minimum => 10)
|
223
|
+
end
|
224
|
+
|
225
|
+
it "should coerce minimum to an integer" do
|
226
|
+
@session.should_not have_no_css("h2.head", :minimum => "4") # edge case
|
227
|
+
@session.should_not have_no_css("h2", :minimum => "3")
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
context "with text" do
|
232
|
+
it "should discard all matches where the given string is not contained" do
|
233
|
+
@session.should_not have_no_css("p a", :text => "Redirect", :count => 1)
|
234
|
+
@session.should have_no_css("p a", :text => "Doesnotexist")
|
235
|
+
end
|
236
|
+
|
237
|
+
it "should discard all matches where the given regexp is not matched" do
|
238
|
+
@session.should_not have_no_css("p a", :text => /re[dab]i/i, :count => 1)
|
239
|
+
@session.should have_no_css("p a", :text => /Red$/)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
@@ -0,0 +1,192 @@
|
|
1
|
+
shared_examples_for "has_field" do
|
2
|
+
describe '#has_field' do
|
3
|
+
before { @session.visit('/form') }
|
4
|
+
|
5
|
+
it "should be true if the field is on the page" do
|
6
|
+
@session.should have_field('Dog')
|
7
|
+
@session.should have_field('form_description')
|
8
|
+
@session.should have_field('Region')
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be false if the field is not on the page" do
|
12
|
+
@session.should_not have_field('Monkey')
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'with value' do
|
16
|
+
it "should be true if a field with the given value is on the page" do
|
17
|
+
@session.should have_field('First Name', :with => 'John')
|
18
|
+
@session.should have_field('Phone', :with => '+1 555 7021')
|
19
|
+
@session.should have_field('Street', :with => 'Sesame street 66')
|
20
|
+
@session.should have_field('Description', :with => 'Descriptive text goes here')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should be false if the given field is not on the page" do
|
24
|
+
@session.should_not have_field('First Name', :with => 'Peter')
|
25
|
+
@session.should_not have_field('Wrong Name', :with => 'John')
|
26
|
+
@session.should_not have_field('Description', :with => 'Monkey')
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should be true after the field has been filled in with the given value" do
|
30
|
+
@session.fill_in('First Name', :with => 'Jonas')
|
31
|
+
@session.should have_field('First Name', :with => 'Jonas')
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should be false after the field has been filled in with a different value" do
|
35
|
+
@session.fill_in('First Name', :with => 'Jonas')
|
36
|
+
@session.should_not have_field('First Name', :with => 'John')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#has_no_field' do
|
42
|
+
before { @session.visit('/form') }
|
43
|
+
|
44
|
+
it "should be false if the field is on the page" do
|
45
|
+
@session.should_not have_no_field('Dog')
|
46
|
+
@session.should_not have_no_field('form_description')
|
47
|
+
@session.should_not have_no_field('Region')
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should be true if the field is not on the page" do
|
51
|
+
@session.should have_no_field('Monkey')
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'with value' do
|
55
|
+
it "should be false if a field with the given value is on the page" do
|
56
|
+
@session.should_not have_no_field('First Name', :with => 'John')
|
57
|
+
@session.should_not have_no_field('Phone', :with => '+1 555 7021')
|
58
|
+
@session.should_not have_no_field('Street', :with => 'Sesame street 66')
|
59
|
+
@session.should_not have_no_field('Description', :with => 'Descriptive text goes here')
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should be true if the given field is not on the page" do
|
63
|
+
@session.should have_no_field('First Name', :with => 'Peter')
|
64
|
+
@session.should have_no_field('Wrong Name', :with => 'John')
|
65
|
+
@session.should have_no_field('Description', :with => 'Monkey')
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should be false after the field has been filled in with the given value" do
|
69
|
+
@session.fill_in('First Name', :with => 'Jonas')
|
70
|
+
@session.should_not have_no_field('First Name', :with => 'Jonas')
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should be true after the field has been filled in with a different value" do
|
74
|
+
@session.fill_in('First Name', :with => 'Jonas')
|
75
|
+
@session.should have_no_field('First Name', :with => 'John')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#has_checked_field?' do
|
81
|
+
before { @session.visit('/form') }
|
82
|
+
|
83
|
+
it "should be true if a checked field is on the page" do
|
84
|
+
@session.should have_checked_field('gender_female')
|
85
|
+
@session.should have_checked_field('Hamster')
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should be false if an unchecked field is on the page" do
|
89
|
+
@session.should_not have_checked_field('form_pets_cat')
|
90
|
+
@session.should_not have_checked_field('Male')
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should be false if no field is on the page" do
|
94
|
+
@session.should_not have_checked_field('Does Not Exist')
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should be true after an unchecked checkbox is checked" do
|
98
|
+
@session.check('form_pets_cat')
|
99
|
+
@session.should have_checked_field('form_pets_cat')
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should be false after a checked checkbox is unchecked" do
|
103
|
+
@session.uncheck('form_pets_dog')
|
104
|
+
@session.should_not have_checked_field('form_pets_dog')
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should be true after an unchecked radio button is chosen" do
|
108
|
+
@session.choose('gender_male')
|
109
|
+
@session.should have_checked_field('gender_male')
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should be false after another radio button in the group is chosen" do
|
113
|
+
@session.choose('gender_male')
|
114
|
+
@session.should_not have_checked_field('gender_female')
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe '#has_no_checked_field?' do
|
119
|
+
before { @session.visit('/form') }
|
120
|
+
|
121
|
+
it "should be false if a checked field is on the page" do
|
122
|
+
@session.should_not have_no_checked_field('gender_female')
|
123
|
+
@session.should_not have_no_checked_field('Hamster')
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should be true if an unchecked field is on the page" do
|
127
|
+
@session.should have_no_checked_field('form_pets_cat')
|
128
|
+
@session.should have_no_checked_field('Male')
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should be true if no field is on the page" do
|
132
|
+
@session.should have_no_checked_field('Does Not Exist')
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe '#has_unchecked_field?' do
|
137
|
+
before { @session.visit('/form') }
|
138
|
+
|
139
|
+
it "should be false if a checked field is on the page" do
|
140
|
+
@session.should_not have_unchecked_field('gender_female')
|
141
|
+
@session.should_not have_unchecked_field('Hamster')
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should be true if an unchecked field is on the page" do
|
145
|
+
@session.should have_unchecked_field('form_pets_cat')
|
146
|
+
@session.should have_unchecked_field('Male')
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should be false if no field is on the page" do
|
150
|
+
@session.should_not have_unchecked_field('Does Not Exist')
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should be false after an unchecked checkbox is checked" do
|
154
|
+
@session.check('form_pets_cat')
|
155
|
+
@session.should_not have_unchecked_field('form_pets_cat')
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should be true after a checked checkbox is unchecked" do
|
159
|
+
@session.uncheck('form_pets_dog')
|
160
|
+
@session.should have_unchecked_field('form_pets_dog')
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should be false after an unchecked radio button is chosen" do
|
164
|
+
@session.choose('gender_male')
|
165
|
+
@session.should_not have_unchecked_field('gender_male')
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should be true after another radio button in the group is chosen" do
|
169
|
+
@session.choose('gender_male')
|
170
|
+
@session.should have_unchecked_field('gender_female')
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
describe '#has_no_unchecked_field?' do
|
175
|
+
before { @session.visit('/form') }
|
176
|
+
|
177
|
+
it "should be true if a checked field is on the page" do
|
178
|
+
@session.should have_no_unchecked_field('gender_female')
|
179
|
+
@session.should have_no_unchecked_field('Hamster')
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should be false if an unchecked field is on the page" do
|
183
|
+
@session.should_not have_no_unchecked_field('form_pets_cat')
|
184
|
+
@session.should_not have_no_unchecked_field('Male')
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should be true if no field is on the page" do
|
188
|
+
@session.should have_no_unchecked_field('Does Not Exist')
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
shared_examples_for "has_link" do
|
2
|
+
|
3
|
+
describe '#has_link?' do
|
4
|
+
before do
|
5
|
+
@session.visit('/with_html')
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should be true if the given link is on the page" do
|
9
|
+
@session.should have_link('foo')
|
10
|
+
@session.should have_link('awesome title')
|
11
|
+
@session.should have_link('A link', :href => '/with_simple_html')
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should be false if the given link is not on the page" do
|
15
|
+
@session.should_not have_link('monkey')
|
16
|
+
@session.should_not have_link('A link', :href => '/non-existant-href')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#has_no_link?' do
|
21
|
+
before do
|
22
|
+
@session.visit('/with_html')
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should be false if the given link is on the page" do
|
26
|
+
@session.should_not have_no_link('foo')
|
27
|
+
@session.should_not have_no_link('awesome title')
|
28
|
+
@session.should_not have_no_link('A link', :href => '/with_simple_html')
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should be true if the given link is not on the page" do
|
32
|
+
@session.should have_no_link('monkey')
|
33
|
+
@session.should have_no_link('A link', :href => '/non-existant-href')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1,129 @@
|
|
1
|
+
shared_examples_for "has_select" do
|
2
|
+
describe '#has_select?' do
|
3
|
+
before { @session.visit('/form') }
|
4
|
+
|
5
|
+
it "should be true if the field is on the page" do
|
6
|
+
@session.should have_select('Locale')
|
7
|
+
@session.should have_select('form_region')
|
8
|
+
@session.should have_select('Languages')
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be false if the field is not on the page" do
|
12
|
+
@session.should_not have_select('Monkey')
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'with selected value' do
|
16
|
+
it "should be true if a field with the given value is on the page" do
|
17
|
+
@session.should have_select('form_locale', :selected => 'English')
|
18
|
+
@session.should have_select('Region', :selected => 'Norway')
|
19
|
+
@session.should have_select('Underwear', :selected => ['Briefs', 'Commando'])
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should be false if the given field is not on the page" do
|
23
|
+
@session.should_not have_select('Locale', :selected => 'Swedish')
|
24
|
+
@session.should_not have_select('Does not exist', :selected => 'John')
|
25
|
+
@session.should_not have_select('City', :selected => 'Not there')
|
26
|
+
@session.should_not have_select('Underwear', :selected => ['Briefs', 'Nonexistant'])
|
27
|
+
@session.should_not have_select('Underwear', :selected => ['Briefs', 'Boxers'])
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should be true after the given value is selected" do
|
31
|
+
@session.select('Swedish', :from => 'Locale')
|
32
|
+
@session.should have_select('Locale', :selected => 'Swedish')
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should be false after a different value is selected" do
|
36
|
+
@session.select('Swedish', :from => 'Locale')
|
37
|
+
@session.should_not have_select('Locale', :selected => 'English')
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should be true after the given values are selected" do
|
41
|
+
@session.select('Boxers', :from => 'Underwear')
|
42
|
+
@session.should have_select('Underwear', :selected => ['Briefs', 'Boxers', 'Commando'])
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should be false after one of the values is unselected" do
|
46
|
+
@session.unselect('Briefs', :from => 'Underwear')
|
47
|
+
@session.should_not have_select('Underwear', :selected => ['Briefs', 'Commando'])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'with options' do
|
52
|
+
it "should be true if a field with the given options is on the page" do
|
53
|
+
@session.should have_select('form_locale', :options => ['English'])
|
54
|
+
@session.should have_select('Region', :options => ['Norway', 'Sweden'])
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should be false if the given field is not on the page" do
|
58
|
+
@session.should_not have_select('Locale', :options => ['Not there'])
|
59
|
+
@session.should_not have_select('Does not exist', :options => ['John'])
|
60
|
+
@session.should_not have_select('City', :options => ['London', 'Made up city'])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#has_no_select?' do
|
66
|
+
before { @session.visit('/form') }
|
67
|
+
|
68
|
+
it "should be false if the field is on the page" do
|
69
|
+
@session.should_not have_no_select('Locale')
|
70
|
+
@session.should_not have_no_select('form_region')
|
71
|
+
@session.should_not have_no_select('Languages')
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should be true if the field is not on the page" do
|
75
|
+
@session.should have_no_select('Monkey')
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'with selected value' do
|
79
|
+
it "should be false if a field with the given value is on the page" do
|
80
|
+
@session.should_not have_no_select('form_locale', :selected => 'English')
|
81
|
+
@session.should_not have_no_select('Region', :selected => 'Norway')
|
82
|
+
@session.should_not have_no_select('Underwear', :selected => ['Briefs', 'Commando'])
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should be true if the given field is not on the page" do
|
86
|
+
@session.should have_no_select('Locale', :selected => 'Swedish')
|
87
|
+
@session.should have_no_select('Does not exist', :selected => 'John')
|
88
|
+
@session.should have_no_select('City', :selected => 'Not there')
|
89
|
+
@session.should have_no_select('Underwear', :selected => ['Briefs', 'Nonexistant'])
|
90
|
+
@session.should have_no_select('Underwear', :selected => ['Briefs', 'Boxers'])
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should be false after the given value is selected" do
|
94
|
+
@session.select('Swedish', :from => 'Locale')
|
95
|
+
@session.should_not have_no_select('Locale', :selected => 'Swedish')
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should be true after a different value is selected" do
|
99
|
+
@session.select('Swedish', :from => 'Locale')
|
100
|
+
@session.should have_no_select('Locale', :selected => 'English')
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should be false after the given values are selected" do
|
104
|
+
@session.select('Boxers', :from => 'Underwear')
|
105
|
+
@session.should_not have_no_select('Underwear', :selected => ['Briefs', 'Boxers', 'Commando'])
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should be true after one of the values is unselected" do
|
109
|
+
@session.unselect('Briefs', :from => 'Underwear')
|
110
|
+
@session.should have_no_select('Underwear', :selected => ['Briefs', 'Commando'])
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'with options' do
|
115
|
+
it "should be false if a field with the given options is on the page" do
|
116
|
+
@session.should_not have_no_select('form_locale', :options => ['English'])
|
117
|
+
@session.should_not have_no_select('Region', :options => ['Norway', 'Sweden'])
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should be true if the given field is not on the page" do
|
121
|
+
@session.should have_no_select('Locale', :options => ['Not there'])
|
122
|
+
@session.should have_no_select('Does not exist', :options => ['John'])
|
123
|
+
@session.should have_no_select('City', :options => ['London', 'Made up city'])
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
|