bbc-capybara 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +325 -0
- data/License.txt +22 -0
- data/README.md +815 -0
- data/lib/capybara.rb +368 -0
- data/lib/capybara/cucumber.rb +25 -0
- data/lib/capybara/driver/base.rb +64 -0
- data/lib/capybara/driver/node.rb +74 -0
- data/lib/capybara/dsl.rb +50 -0
- data/lib/capybara/node/actions.rb +146 -0
- data/lib/capybara/node/base.rb +63 -0
- data/lib/capybara/node/document.rb +25 -0
- data/lib/capybara/node/element.rb +201 -0
- data/lib/capybara/node/finders.rb +154 -0
- data/lib/capybara/node/matchers.rb +442 -0
- data/lib/capybara/node/simple.rb +132 -0
- data/lib/capybara/query.rb +63 -0
- data/lib/capybara/rack_test/browser.rb +126 -0
- data/lib/capybara/rack_test/driver.rb +80 -0
- data/lib/capybara/rack_test/form.rb +80 -0
- data/lib/capybara/rack_test/node.rb +121 -0
- data/lib/capybara/rails.rb +17 -0
- data/lib/capybara/rspec.rb +26 -0
- data/lib/capybara/rspec/features.rb +22 -0
- data/lib/capybara/rspec/matchers.rb +152 -0
- data/lib/capybara/selector.rb +156 -0
- data/lib/capybara/selenium/driver.rb +169 -0
- data/lib/capybara/selenium/node.rb +91 -0
- data/lib/capybara/server.rb +87 -0
- data/lib/capybara/session.rb +322 -0
- data/lib/capybara/spec/driver.rb +329 -0
- data/lib/capybara/spec/fixtures/capybara.jpg +3 -0
- data/lib/capybara/spec/fixtures/test_file.txt +1 -0
- data/lib/capybara/spec/public/jquery-ui.js +791 -0
- data/lib/capybara/spec/public/jquery.js +9046 -0
- data/lib/capybara/spec/public/test.js +43 -0
- data/lib/capybara/spec/session.rb +148 -0
- data/lib/capybara/spec/session/all_spec.rb +78 -0
- data/lib/capybara/spec/session/attach_file_spec.rb +76 -0
- data/lib/capybara/spec/session/check_spec.rb +68 -0
- data/lib/capybara/spec/session/choose_spec.rb +29 -0
- data/lib/capybara/spec/session/click_button_spec.rb +305 -0
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +37 -0
- data/lib/capybara/spec/session/click_link_spec.rb +120 -0
- data/lib/capybara/spec/session/current_url_spec.rb +83 -0
- data/lib/capybara/spec/session/fill_in_spec.rb +127 -0
- data/lib/capybara/spec/session/find_button_spec.rb +18 -0
- data/lib/capybara/spec/session/find_by_id_spec.rb +18 -0
- data/lib/capybara/spec/session/find_field_spec.rb +26 -0
- data/lib/capybara/spec/session/find_link_spec.rb +19 -0
- data/lib/capybara/spec/session/find_spec.rb +168 -0
- data/lib/capybara/spec/session/first_spec.rb +105 -0
- data/lib/capybara/spec/session/has_button_spec.rb +32 -0
- data/lib/capybara/spec/session/has_css_spec.rb +243 -0
- data/lib/capybara/spec/session/has_field_spec.rb +192 -0
- data/lib/capybara/spec/session/has_link_spec.rb +37 -0
- data/lib/capybara/spec/session/has_select_spec.rb +129 -0
- data/lib/capybara/spec/session/has_selector_spec.rb +129 -0
- data/lib/capybara/spec/session/has_table_spec.rb +34 -0
- data/lib/capybara/spec/session/has_text_spec.rb +138 -0
- data/lib/capybara/spec/session/has_xpath_spec.rb +123 -0
- data/lib/capybara/spec/session/headers.rb +19 -0
- data/lib/capybara/spec/session/javascript.rb +312 -0
- data/lib/capybara/spec/session/response_code.rb +19 -0
- data/lib/capybara/spec/session/select_spec.rb +119 -0
- data/lib/capybara/spec/session/text_spec.rb +24 -0
- data/lib/capybara/spec/session/uncheck_spec.rb +21 -0
- data/lib/capybara/spec/session/unselect_spec.rb +67 -0
- data/lib/capybara/spec/session/within_spec.rb +178 -0
- data/lib/capybara/spec/test_app.rb +156 -0
- data/lib/capybara/spec/views/buttons.erb +4 -0
- data/lib/capybara/spec/views/fieldsets.erb +29 -0
- data/lib/capybara/spec/views/form.erb +366 -0
- data/lib/capybara/spec/views/frame_one.erb +8 -0
- data/lib/capybara/spec/views/frame_two.erb +8 -0
- data/lib/capybara/spec/views/header_links.erb +7 -0
- data/lib/capybara/spec/views/host_links.erb +12 -0
- data/lib/capybara/spec/views/popup_one.erb +8 -0
- data/lib/capybara/spec/views/popup_two.erb +8 -0
- data/lib/capybara/spec/views/postback.erb +13 -0
- data/lib/capybara/spec/views/tables.erb +62 -0
- data/lib/capybara/spec/views/with_html.erb +75 -0
- data/lib/capybara/spec/views/with_html_entities.erb +1 -0
- data/lib/capybara/spec/views/with_js.erb +53 -0
- data/lib/capybara/spec/views/with_scope.erb +36 -0
- data/lib/capybara/spec/views/with_simple_html.erb +1 -0
- data/lib/capybara/spec/views/within_frames.erb +10 -0
- data/lib/capybara/spec/views/within_popups.erb +25 -0
- data/lib/capybara/util/save_and_open_page.rb +45 -0
- data/lib/capybara/util/timeout.rb +27 -0
- data/lib/capybara/version.rb +3 -0
- data/spec/basic_node_spec.rb +89 -0
- data/spec/capybara_spec.rb +46 -0
- data/spec/driver/rack_test_driver_spec.rb +90 -0
- data/spec/driver/selenium_driver_spec.rb +55 -0
- data/spec/dsl_spec.rb +255 -0
- data/spec/fixtures/selenium_driver_rspec_failure.rb +8 -0
- data/spec/fixtures/selenium_driver_rspec_success.rb +8 -0
- data/spec/rspec/features_spec.rb +43 -0
- data/spec/rspec/matchers_spec.rb +564 -0
- data/spec/rspec_spec.rb +51 -0
- data/spec/save_and_open_page_spec.rb +155 -0
- data/spec/server_spec.rb +74 -0
- data/spec/session/rack_test_session_spec.rb +61 -0
- data/spec/session/selenium_session_spec.rb +26 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/timeout_spec.rb +28 -0
- metadata +297 -0
@@ -0,0 +1,305 @@
|
|
1
|
+
shared_examples_for "click_button" do
|
2
|
+
describe '#click_button' do
|
3
|
+
before do
|
4
|
+
@session.visit('/form')
|
5
|
+
end
|
6
|
+
|
7
|
+
context "with multiple values with the same name" do
|
8
|
+
it "should use the latest given value" do
|
9
|
+
@session.check('Terms of Use')
|
10
|
+
@session.click_button('awesome')
|
11
|
+
extract_results(@session)['terms_of_use'].should == '1'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "with a form that has a relative url as an action" do
|
16
|
+
it "should post to the correct url" do
|
17
|
+
@session.click_button('Relative Action')
|
18
|
+
@session.current_path.should == '/relative'
|
19
|
+
extract_results(@session)['relative'].should == 'Relative Action'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with a form that has no action specified" do
|
24
|
+
it "should post to the correct url" do
|
25
|
+
@session.click_button('No Action')
|
26
|
+
@session.current_path.should == '/form'
|
27
|
+
extract_results(@session)['no_action'].should == 'No Action'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "with value given on a submit button" do
|
32
|
+
context "on a form with HTML5 fields" do
|
33
|
+
before do
|
34
|
+
@session.click_button('html5_submit')
|
35
|
+
@results = extract_results(@session)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should serialise and submit search fields" do
|
39
|
+
@results['html5_search'].should == 'what are you looking for'
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should serialise and submit email fields" do
|
43
|
+
@results['html5_email'].should == 'person@email.com'
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should serialise and submit url fields" do
|
47
|
+
@results['html5_url'].should == 'http://www.example.com'
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should serialise and submit tel fields" do
|
51
|
+
@results['html5_tel'].should == '911'
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should serialise and submit color fields" do
|
55
|
+
@results['html5_color'].should == '#FFFFFF'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "on an HTML4 form" do
|
60
|
+
before do
|
61
|
+
@session.click_button('awesome')
|
62
|
+
@results = extract_results(@session)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should serialize and submit text fields" do
|
66
|
+
@results['first_name'].should == 'John'
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should escape fields when submitting" do
|
70
|
+
@results['phone'].should == '+1 555 7021'
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should serialize and submit password fields" do
|
74
|
+
@results['password'].should == 'seeekrit'
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should serialize and submit hidden fields" do
|
78
|
+
@results['token'].should == '12345'
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should not serialize fields from other forms" do
|
82
|
+
@results['middle_name'].should be_nil
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should submit the button that was clicked, but not other buttons" do
|
86
|
+
@results['awesome'].should == 'awesome'
|
87
|
+
@results['crappy'].should be_nil
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should serialize radio buttons" do
|
91
|
+
@results['gender'].should == 'female'
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should serialize check boxes" do
|
95
|
+
@results['pets'].should include('dog', 'hamster')
|
96
|
+
@results['pets'].should_not include('cat')
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should serialize text areas" do
|
100
|
+
@results['description'].should == 'Descriptive text goes here'
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should serialize select tag with values" do
|
104
|
+
@results['locale'].should == 'en'
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should serialize select tag without values" do
|
108
|
+
@results['region'].should == 'Norway'
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should serialize first option for select tag with no selection" do
|
112
|
+
@results['city'].should == 'London'
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should not serialize a select tag without options" do
|
116
|
+
@results['tendency'].should be_nil
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should not submit disabled fields" do
|
120
|
+
@results['disabled_text_field'].should be_nil
|
121
|
+
@results['disabled_textarea'].should be_nil
|
122
|
+
@results['disabled_checkbox'].should be_nil
|
123
|
+
@results['disabled_radio'].should be_nil
|
124
|
+
@results['disabled_select'].should be_nil
|
125
|
+
@results['disabled_file'].should be_nil
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context "with id given on a submit button" do
|
131
|
+
it "should submit the associated form" do
|
132
|
+
@session.click_button('awe123')
|
133
|
+
extract_results(@session)['first_name'].should == 'John'
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should work with partial matches" do
|
137
|
+
@session.click_button('Go')
|
138
|
+
@session.body.should include('You landed')
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context "with title given on a submit button" do
|
143
|
+
it "should submit the associated form" do
|
144
|
+
@session.click_button('What an Awesome Button')
|
145
|
+
extract_results(@session)['first_name'].should == 'John'
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should work with partial matches" do
|
149
|
+
@session.click_button('What an Awesome')
|
150
|
+
extract_results(@session)['first_name'].should == 'John'
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
context "with alt given on an image button" do
|
155
|
+
it "should submit the associated form" do
|
156
|
+
@session.click_button('oh hai thar')
|
157
|
+
extract_results(@session)['first_name'].should == 'John'
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should work with partial matches" do
|
161
|
+
@session.click_button('hai')
|
162
|
+
extract_results(@session)['first_name'].should == 'John'
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
context "with value given on an image button" do
|
167
|
+
it "should submit the associated form" do
|
168
|
+
@session.click_button('okay')
|
169
|
+
extract_results(@session)['first_name'].should == 'John'
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should work with partial matches" do
|
173
|
+
@session.click_button('kay')
|
174
|
+
extract_results(@session)['first_name'].should == 'John'
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
context "with id given on an image button" do
|
179
|
+
it "should submit the associated form" do
|
180
|
+
@session.click_button('okay556')
|
181
|
+
extract_results(@session)['first_name'].should == 'John'
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
context "with title given on an image button" do
|
186
|
+
it "should submit the associated form" do
|
187
|
+
@session.click_button('Okay 556 Image')
|
188
|
+
extract_results(@session)['first_name'].should == 'John'
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should work with partial matches" do
|
192
|
+
@session.click_button('Okay 556')
|
193
|
+
extract_results(@session)['first_name'].should == 'John'
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
context "with text given on a button defined by <button> tag" do
|
198
|
+
it "should submit the associated form" do
|
199
|
+
@session.click_button('Click me')
|
200
|
+
extract_results(@session)['first_name'].should == 'John'
|
201
|
+
end
|
202
|
+
|
203
|
+
it "should work with partial matches" do
|
204
|
+
@session.click_button('Click')
|
205
|
+
extract_results(@session)['first_name'].should == 'John'
|
206
|
+
end
|
207
|
+
|
208
|
+
it "should prefer exact matches over partial matches" do
|
209
|
+
@session.click_button('Just an input')
|
210
|
+
extract_results(@session)['button'].should == 'button_second'
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
context "with id given on a button defined by <button> tag" do
|
215
|
+
it "should submit the associated form" do
|
216
|
+
@session.click_button('click_me_123')
|
217
|
+
extract_results(@session)['first_name'].should == 'John'
|
218
|
+
end
|
219
|
+
|
220
|
+
it "should serialize and send GET forms" do
|
221
|
+
@session.visit('/form')
|
222
|
+
@session.click_button('med')
|
223
|
+
@results = extract_results(@session)
|
224
|
+
@results['middle_name'].should == 'Darren'
|
225
|
+
@results['foo'].should be_nil
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
context "with value given on a button defined by <button> tag" do
|
230
|
+
it "should submit the associated form" do
|
231
|
+
@session.click_button('click_me')
|
232
|
+
extract_results(@session)['first_name'].should == 'John'
|
233
|
+
end
|
234
|
+
|
235
|
+
it "should work with partial matches" do
|
236
|
+
@session.click_button('ck_me')
|
237
|
+
extract_results(@session)['first_name'].should == 'John'
|
238
|
+
end
|
239
|
+
|
240
|
+
it "should prefer exact matches over partial matches" do
|
241
|
+
@session.click_button('Just a button')
|
242
|
+
extract_results(@session)['button'].should == 'Just a button'
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
context "with title given on a button defined by <button> tag" do
|
247
|
+
it "should submit the associated form" do
|
248
|
+
@session.click_button('Click Title button')
|
249
|
+
extract_results(@session)['first_name'].should == 'John'
|
250
|
+
end
|
251
|
+
|
252
|
+
it "should work with partial matches" do
|
253
|
+
@session.click_button('Click Title')
|
254
|
+
extract_results(@session)['first_name'].should == 'John'
|
255
|
+
end
|
256
|
+
end
|
257
|
+
context "with a locator that doesn't exist" do
|
258
|
+
it "should raise an error" do
|
259
|
+
msg = "no button with value or id or text 'does not exist' found"
|
260
|
+
running do
|
261
|
+
@session.click_button('does not exist')
|
262
|
+
end.should raise_error(Capybara::ElementNotFound, msg)
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
it "should serialize and send valueless buttons that were clicked" do
|
267
|
+
@session.click_button('No Value!')
|
268
|
+
@results = extract_results(@session)
|
269
|
+
@results['no_value'].should_not be_nil
|
270
|
+
end
|
271
|
+
|
272
|
+
it "should not send image buttons that were not clicked" do
|
273
|
+
@session.click_button('Click me!')
|
274
|
+
@results = extract_results(@session)
|
275
|
+
@results['okay'].should be_nil
|
276
|
+
end
|
277
|
+
|
278
|
+
it "should serialize and send GET forms" do
|
279
|
+
@session.visit('/form')
|
280
|
+
@session.click_button('med')
|
281
|
+
@results = extract_results(@session)
|
282
|
+
@results['middle_name'].should == 'Darren'
|
283
|
+
@results['foo'].should be_nil
|
284
|
+
end
|
285
|
+
|
286
|
+
it "should follow redirects" do
|
287
|
+
@session.click_button('Go FAR')
|
288
|
+
@session.current_url.should match(%r{/landed$})
|
289
|
+
@session.body.should include('You landed')
|
290
|
+
end
|
291
|
+
|
292
|
+
it "should post pack to the same URL when no action given" do
|
293
|
+
@session.visit('/postback')
|
294
|
+
@session.click_button('With no action')
|
295
|
+
@session.body.should include('Postback')
|
296
|
+
end
|
297
|
+
|
298
|
+
it "should post pack to the same URL when blank action given" do
|
299
|
+
@session.visit('/postback')
|
300
|
+
@session.click_button('With blank action')
|
301
|
+
@session.body.should include('Postback')
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
shared_examples_for "click_link_or_button" do
|
2
|
+
describe '#click' do
|
3
|
+
it "should click on a link" do
|
4
|
+
@session.visit('/with_html')
|
5
|
+
@session.click_link_or_button('labore')
|
6
|
+
@session.body.should include('Bar')
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should click on a button" do
|
10
|
+
@session.visit('/form')
|
11
|
+
@session.click_link_or_button('awe123')
|
12
|
+
extract_results(@session)['first_name'].should == 'John'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should click on a button with no type attribute" do
|
16
|
+
@session.visit('/form')
|
17
|
+
@session.click_link_or_button('no_type')
|
18
|
+
extract_results(@session)['first_name'].should == 'John'
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should be aliased as click_on" do
|
22
|
+
@session.visit('/form')
|
23
|
+
@session.click_on('awe123')
|
24
|
+
extract_results(@session)['first_name'].should == 'John'
|
25
|
+
end
|
26
|
+
|
27
|
+
context "with a locator that doesn't exist" do
|
28
|
+
it "should raise an error" do
|
29
|
+
@session.visit('/with_html')
|
30
|
+
msg = "no link or button 'does not exist' found"
|
31
|
+
running do
|
32
|
+
@session.click_link_or_button('does not exist')
|
33
|
+
end.should raise_error(Capybara::ElementNotFound, msg)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
shared_examples_for "click_link" do
|
2
|
+
describe '#click_link' do
|
3
|
+
before do
|
4
|
+
@session.visit('/with_html')
|
5
|
+
end
|
6
|
+
|
7
|
+
context "with id given" do
|
8
|
+
it "should take user to the linked page" do
|
9
|
+
@session.click_link('foo')
|
10
|
+
@session.body.should include('Another World')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "with text given" do
|
15
|
+
it "should take user to the linked page" do
|
16
|
+
@session.click_link('labore')
|
17
|
+
@session.body.should include('Bar')
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should accept partial matches" do
|
21
|
+
@session.click_link('abo')
|
22
|
+
@session.body.should include('Bar')
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should prefer exact matches over partial matches" do
|
26
|
+
@session.click_link('A link')
|
27
|
+
@session.body.should include('Bar')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "with title given" do
|
32
|
+
it "should take user to the linked page" do
|
33
|
+
@session.click_link('awesome title')
|
34
|
+
@session.body.should include('Bar')
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should accept partial matches" do
|
38
|
+
@session.click_link('some tit')
|
39
|
+
@session.body.should include('Bar')
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should prefer exact matches over partial matches" do
|
43
|
+
@session.click_link('a fine link')
|
44
|
+
@session.body.should include('Bar')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "with alternative text given to a contained image" do
|
49
|
+
it "should take user to the linked page" do
|
50
|
+
@session.click_link('awesome image')
|
51
|
+
@session.body.should include('Bar')
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should take user to the linked page" do
|
55
|
+
@session.click_link('some imag')
|
56
|
+
@session.body.should include('Bar')
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should prefer exact matches over partial matches" do
|
60
|
+
@session.click_link('fine image')
|
61
|
+
@session.body.should include('Bar')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "with a locator that doesn't exist" do
|
66
|
+
it "should raise an error" do
|
67
|
+
msg = "no link with title, id or text 'does not exist' found"
|
68
|
+
running do
|
69
|
+
@session.click_link('does not exist')
|
70
|
+
end.should raise_error(Capybara::ElementNotFound, msg)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should follow relative links" do
|
75
|
+
@session.visit('/')
|
76
|
+
@session.click_link('Relative')
|
77
|
+
@session.body.should include('This is a test')
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should follow redirects" do
|
81
|
+
@session.click_link('Redirect')
|
82
|
+
@session.body.should include('You landed')
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should follow redirects" do
|
86
|
+
@session.click_link('BackToMyself')
|
87
|
+
@session.body.should include('This is a test')
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should add query string to current URL with naked query string" do
|
91
|
+
@session.click_link('Naked Query String')
|
92
|
+
@session.body.should include('Query String sent')
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should do nothing on anchor links" do
|
96
|
+
@session.fill_in("test_field", :with => 'blah')
|
97
|
+
@session.click_link('Anchor')
|
98
|
+
@session.find_field("test_field").value.should == 'blah'
|
99
|
+
@session.click_link('Blank Anchor')
|
100
|
+
@session.find_field("test_field").value.should == 'blah'
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should do nothing on URL+anchor links for the same page" do
|
104
|
+
@session.fill_in("test_field", :with => 'blah')
|
105
|
+
@session.click_link('Anchor on same page')
|
106
|
+
@session.find_field("test_field").value.should == 'blah'
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should follow link on URL+anchor links for a different page" do
|
110
|
+
@session.click_link('Anchor on different page')
|
111
|
+
@session.body.should include('Bar')
|
112
|
+
end
|
113
|
+
|
114
|
+
it "raise an error with links with no href" do
|
115
|
+
running do
|
116
|
+
@session.click_link('No Href')
|
117
|
+
end.should raise_error(Capybara::ElementNotFound)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|