nimboids-capybara 1.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.
Files changed (105) hide show
  1. data/History.txt +289 -0
  2. data/README.rdoc +722 -0
  3. data/lib/capybara.rb +252 -0
  4. data/lib/capybara/cucumber.rb +28 -0
  5. data/lib/capybara/driver/base.rb +64 -0
  6. data/lib/capybara/driver/node.rb +74 -0
  7. data/lib/capybara/dsl.rb +168 -0
  8. data/lib/capybara/node/actions.rb +162 -0
  9. data/lib/capybara/node/base.rb +63 -0
  10. data/lib/capybara/node/document.rb +25 -0
  11. data/lib/capybara/node/element.rb +201 -0
  12. data/lib/capybara/node/finders.rb +197 -0
  13. data/lib/capybara/node/matchers.rb +417 -0
  14. data/lib/capybara/node/simple.rb +132 -0
  15. data/lib/capybara/rack_test/browser.rb +121 -0
  16. data/lib/capybara/rack_test/driver.rb +80 -0
  17. data/lib/capybara/rack_test/form.rb +80 -0
  18. data/lib/capybara/rack_test/node.rb +105 -0
  19. data/lib/capybara/rails.rb +17 -0
  20. data/lib/capybara/rspec.rb +26 -0
  21. data/lib/capybara/rspec/features.rb +22 -0
  22. data/lib/capybara/rspec/matchers.rb +154 -0
  23. data/lib/capybara/selector.rb +89 -0
  24. data/lib/capybara/selenium/driver.rb +163 -0
  25. data/lib/capybara/selenium/node.rb +91 -0
  26. data/lib/capybara/server.rb +90 -0
  27. data/lib/capybara/session.rb +321 -0
  28. data/lib/capybara/spec/driver.rb +301 -0
  29. data/lib/capybara/spec/fixtures/capybara.jpg +3 -0
  30. data/lib/capybara/spec/fixtures/test_file.txt +1 -0
  31. data/lib/capybara/spec/public/test.js +43 -0
  32. data/lib/capybara/spec/session.rb +154 -0
  33. data/lib/capybara/spec/session/all_spec.rb +78 -0
  34. data/lib/capybara/spec/session/attach_file_spec.rb +73 -0
  35. data/lib/capybara/spec/session/check_spec.rb +65 -0
  36. data/lib/capybara/spec/session/choose_spec.rb +26 -0
  37. data/lib/capybara/spec/session/click_button_spec.rb +304 -0
  38. data/lib/capybara/spec/session/click_link_or_button_spec.rb +36 -0
  39. data/lib/capybara/spec/session/click_link_spec.rb +119 -0
  40. data/lib/capybara/spec/session/current_host_spec.rb +68 -0
  41. data/lib/capybara/spec/session/current_url_spec.rb +15 -0
  42. data/lib/capybara/spec/session/fill_in_spec.rb +125 -0
  43. data/lib/capybara/spec/session/find_button_spec.rb +18 -0
  44. data/lib/capybara/spec/session/find_by_id_spec.rb +18 -0
  45. data/lib/capybara/spec/session/find_field_spec.rb +26 -0
  46. data/lib/capybara/spec/session/find_link_spec.rb +19 -0
  47. data/lib/capybara/spec/session/find_spec.rb +149 -0
  48. data/lib/capybara/spec/session/first_spec.rb +105 -0
  49. data/lib/capybara/spec/session/has_button_spec.rb +32 -0
  50. data/lib/capybara/spec/session/has_content_spec.rb +106 -0
  51. data/lib/capybara/spec/session/has_css_spec.rb +243 -0
  52. data/lib/capybara/spec/session/has_field_spec.rb +192 -0
  53. data/lib/capybara/spec/session/has_link_spec.rb +37 -0
  54. data/lib/capybara/spec/session/has_select_spec.rb +129 -0
  55. data/lib/capybara/spec/session/has_selector_spec.rb +129 -0
  56. data/lib/capybara/spec/session/has_table_spec.rb +96 -0
  57. data/lib/capybara/spec/session/has_xpath_spec.rb +123 -0
  58. data/lib/capybara/spec/session/headers.rb +19 -0
  59. data/lib/capybara/spec/session/javascript.rb +289 -0
  60. data/lib/capybara/spec/session/response_code.rb +19 -0
  61. data/lib/capybara/spec/session/select_spec.rb +113 -0
  62. data/lib/capybara/spec/session/text_spec.rb +19 -0
  63. data/lib/capybara/spec/session/uncheck_spec.rb +21 -0
  64. data/lib/capybara/spec/session/unselect_spec.rb +61 -0
  65. data/lib/capybara/spec/session/within_spec.rb +178 -0
  66. data/lib/capybara/spec/test_app.rb +142 -0
  67. data/lib/capybara/spec/views/buttons.erb +4 -0
  68. data/lib/capybara/spec/views/fieldsets.erb +29 -0
  69. data/lib/capybara/spec/views/form.erb +365 -0
  70. data/lib/capybara/spec/views/frame_one.erb +8 -0
  71. data/lib/capybara/spec/views/frame_two.erb +8 -0
  72. data/lib/capybara/spec/views/header_links.erb +7 -0
  73. data/lib/capybara/spec/views/host_links.erb +12 -0
  74. data/lib/capybara/spec/views/popup_one.erb +8 -0
  75. data/lib/capybara/spec/views/popup_two.erb +8 -0
  76. data/lib/capybara/spec/views/postback.erb +13 -0
  77. data/lib/capybara/spec/views/tables.erb +122 -0
  78. data/lib/capybara/spec/views/with_html.erb +78 -0
  79. data/lib/capybara/spec/views/with_html_entities.erb +1 -0
  80. data/lib/capybara/spec/views/with_js.erb +48 -0
  81. data/lib/capybara/spec/views/with_scope.erb +36 -0
  82. data/lib/capybara/spec/views/with_simple_html.erb +1 -0
  83. data/lib/capybara/spec/views/within_frames.erb +10 -0
  84. data/lib/capybara/spec/views/within_popups.erb +25 -0
  85. data/lib/capybara/util/save_and_open_page.rb +44 -0
  86. data/lib/capybara/util/timeout.rb +27 -0
  87. data/lib/capybara/version.rb +3 -0
  88. data/spec/basic_node_spec.rb +77 -0
  89. data/spec/capybara_spec.rb +46 -0
  90. data/spec/driver/rack_test_driver_spec.rb +89 -0
  91. data/spec/driver/selenium_driver_spec.rb +50 -0
  92. data/spec/dsl_spec.rb +253 -0
  93. data/spec/fixtures/selenium_driver_rspec_failure.rb +8 -0
  94. data/spec/fixtures/selenium_driver_rspec_success.rb +8 -0
  95. data/spec/rspec/features_spec.rb +45 -0
  96. data/spec/rspec/matchers_spec.rb +495 -0
  97. data/spec/rspec_spec.rb +53 -0
  98. data/spec/save_and_open_page_spec.rb +155 -0
  99. data/spec/server_spec.rb +89 -0
  100. data/spec/session/rack_test_session_spec.rb +55 -0
  101. data/spec/session/selenium_session_spec.rb +26 -0
  102. data/spec/spec_helper.rb +30 -0
  103. data/spec/string_spec.rb +77 -0
  104. data/spec/timeout_spec.rb +28 -0
  105. metadata +346 -0
@@ -0,0 +1,301 @@
1
+ require 'capybara/spec/test_app'
2
+
3
+ shared_examples_for 'driver' do
4
+
5
+ describe '#visit' do
6
+ it "should move to another page" do
7
+ @driver.visit('/')
8
+ @driver.body.should include('Hello world!')
9
+ @driver.visit('/foo')
10
+ @driver.body.should include('Another World')
11
+ end
12
+
13
+ it "should show the correct URL" do
14
+ @driver.visit('/foo')
15
+ @driver.current_url.should include('/foo')
16
+ end
17
+ end
18
+
19
+ describe '#body' do
20
+ it "should return text reponses" do
21
+ @driver.visit('/')
22
+ @driver.body.should include('Hello world!')
23
+ end
24
+
25
+ it "should return the full response html" do
26
+ @driver.visit('/with_simple_html')
27
+ @driver.body.should include('Bar')
28
+ end
29
+
30
+ if "".respond_to?(:encoding)
31
+ context "encoding of response between ascii and utf8" do
32
+ it "should be valid with html entities" do
33
+ @driver.visit('/with_html_entities')
34
+ lambda { @driver.body.encode!("UTF-8") }.should_not raise_error
35
+ end
36
+
37
+ it "should be valid without html entities" do
38
+ @driver.visit('/with_html')
39
+ lambda { @driver.body.encode!("UTF-8") }.should_not raise_error
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ describe '#find' do
46
+ context "with xpath selector" do
47
+ before do
48
+ @driver.visit('/with_html')
49
+ end
50
+
51
+ it "should extract node texts" do
52
+ @driver.find('//a')[0].text.should == 'labore'
53
+ @driver.find('//a')[1].text.should == 'ullamco'
54
+ end
55
+
56
+ it "should extract node attributes" do
57
+ @driver.find('//a')[0][:class].should == 'simple'
58
+ @driver.find('//a')[1][:id].should == 'foo'
59
+ @driver.find('//input')[0][:type].should == 'text'
60
+ end
61
+
62
+ it "should extract boolean node attributes" do
63
+ @driver.find('//input[@id="checked_field"]')[0][:checked].should be_true
64
+ end
65
+
66
+ it "should allow retrieval of the value" do
67
+ @driver.find('//textarea[@id="normal"]').first.value.should == 'banana'
68
+ end
69
+
70
+ it "should not swallow extra newlines in textarea" do
71
+ @driver.find('//textarea[@id="additional_newline"]').first.value.should == "\nbanana"
72
+ end
73
+
74
+ it "should allow assignment of field value" do
75
+ @driver.find('//input').first.value.should == 'monkey'
76
+ @driver.find('//input').first.set('gorilla')
77
+ @driver.find('//input').first.value.should == 'gorilla'
78
+ end
79
+
80
+ it "should extract node tag name" do
81
+ @driver.find('//a')[0].tag_name.should == 'a'
82
+ @driver.find('//a')[1].tag_name.should == 'a'
83
+ @driver.find('//p')[1].tag_name.should == 'p'
84
+ end
85
+
86
+ it "should extract node visibility" do
87
+ @driver.find('//a')[0].should be_visible
88
+
89
+ @driver.find('//div[@id="hidden"]')[0].should_not be_visible
90
+ @driver.find('//div[@id="hidden_via_ancestor"]')[0].should_not be_visible
91
+ end
92
+
93
+ it "should extract node checked state" do
94
+ @driver.visit('/form')
95
+ @driver.find('//input[@id="gender_female"]')[0].should be_checked
96
+ @driver.find('//input[@id="gender_male"]')[0].should_not be_checked
97
+ @driver.find('//h1')[0].should_not be_checked
98
+ end
99
+
100
+ it "should extract node selected state" do
101
+ @driver.visit('/form')
102
+ @driver.find('//option[@value="en"]')[0].should be_selected
103
+ @driver.find('//option[@value="sv"]')[0].should_not be_selected
104
+ @driver.find('//h1')[0].should_not be_selected
105
+ end
106
+
107
+ it "should return document text on /html selector" do
108
+ @driver.visit('/with_simple_html')
109
+ @driver.find('/html')[0].text.should == 'Bar'
110
+ end
111
+ end
112
+ end
113
+ end
114
+
115
+ shared_examples_for "driver with javascript support" do
116
+ before { @driver.visit('/with_js') }
117
+
118
+ describe '#find' do
119
+ it "should find dynamically changed nodes" do
120
+ @driver.find('//p').first.text.should == 'I changed it'
121
+ end
122
+ end
123
+
124
+ describe '#drag_to' do
125
+ it "should drag and drop an object" do
126
+ draggable = @driver.find('//div[@id="drag"]').first
127
+ droppable = @driver.find('//div[@id="drop"]').first
128
+ draggable.drag_to(droppable)
129
+ @driver.find('//div[contains(., "Dropped!")]').should_not be_empty
130
+ end
131
+ end
132
+
133
+ describe "#evaluate_script" do
134
+ it "should return the value of the executed script" do
135
+ @driver.evaluate_script('1+1').should == 2
136
+ end
137
+ end
138
+
139
+ end
140
+
141
+ shared_examples_for "driver with resynchronization support" do
142
+ before { @driver.visit('/with_js') }
143
+ describe "#find" do
144
+ context "with synchronization turned on" do
145
+ before { @driver.options[:resynchronize] = true }
146
+ it "should wait for all ajax requests to finish" do
147
+ @driver.find('//input[@id="fire_ajax_request"]').first.click
148
+ @driver.find('//p[@id="ajax_request_done"]').should_not be_empty
149
+ end
150
+ end
151
+
152
+ context "with resynchronization turned off" do
153
+ before { @driver.options[:resynchronize] = false }
154
+ it "should not wait for ajax requests to finish" do
155
+ @driver.find('//input[@id="fire_ajax_request"]').first.click
156
+ @driver.find('//p[@id="ajax_request_done"]').should be_empty
157
+ end
158
+ end
159
+
160
+ context "with short synchronization timeout" do
161
+ before { @driver.options[:resynchronize] = true }
162
+ before { @driver.options[:resynchronization_timeout] = 0.1 }
163
+
164
+ it "should raise an error" do
165
+ expect do
166
+ @driver.find('//input[@id="fire_ajax_request"]').first.click
167
+ end.to raise_error(Capybara::TimeoutError, "failed to resynchronize, ajax request timed out")
168
+ end
169
+ end
170
+ end
171
+
172
+ after { @driver.options[:resynchronize] = false }
173
+ after { @driver.options[:resynchronization_timeout] = 10 }
174
+ end
175
+
176
+ shared_examples_for "driver with header support" do
177
+ it "should make headers available through response_headers" do
178
+ @driver.visit('/with_simple_html')
179
+ @driver.response_headers['Content-Type'].should =~ /text\/html/
180
+ end
181
+ end
182
+
183
+ shared_examples_for "driver with status code support" do
184
+ it "should make the status code available through status_code" do
185
+ @driver.visit('/with_simple_html')
186
+ @driver.status_code.should == 200
187
+ end
188
+ end
189
+
190
+ shared_examples_for "driver without status code support" do
191
+ it "should raise when trying to access the status code available through status_code" do
192
+ @driver.visit('/with_simple_html')
193
+ lambda {
194
+ @driver.status_code
195
+ }.should raise_error(Capybara::NotSupportedByDriverError)
196
+ end
197
+ end
198
+
199
+ shared_examples_for "driver with frame support" do
200
+ describe '#within_frame' do
201
+ before(:each) do
202
+ @driver.visit('/within_frames')
203
+ end
204
+
205
+ it "should find the div in frameOne" do
206
+ @driver.within_frame("frameOne") do
207
+ @driver.find("//*[@id='divInFrameOne']")[0].text.should eql 'This is the text of divInFrameOne'
208
+ end
209
+ end
210
+ it "should find the div in FrameTwo" do
211
+ @driver.within_frame("frameTwo") do
212
+ @driver.find("//*[@id='divInFrameTwo']")[0].text.should eql 'This is the text of divInFrameTwo'
213
+ end
214
+ end
215
+ it "should find the text div in the main window after finding text in frameOne" do
216
+ @driver.within_frame("frameOne") do
217
+ @driver.find("//*[@id='divInFrameOne']")[0].text.should eql 'This is the text of divInFrameOne'
218
+ end
219
+ @driver.find("//*[@id='divInMainWindow']")[0].text.should eql 'This is the text for divInMainWindow'
220
+ end
221
+ it "should find the text div in the main window after finding text in frameTwo" do
222
+ @driver.within_frame("frameTwo") do
223
+ @driver.find("//*[@id='divInFrameTwo']")[0].text.should eql 'This is the text of divInFrameTwo'
224
+ end
225
+ @driver.find("//*[@id='divInMainWindow']")[0].text.should eql 'This is the text for divInMainWindow'
226
+ end
227
+ end
228
+ end
229
+
230
+ shared_examples_for "driver with support for window switching" do
231
+ describe '#within_window' do
232
+ before(:each) do
233
+ @driver.visit('/within_popups')
234
+ end
235
+ after(:each) do
236
+ @driver.within_window("firstPopup") do
237
+ @driver.evaluate_script('window.close()')
238
+ end
239
+ @driver.within_window("secondPopup") do
240
+ @driver.evaluate_script('window.close()')
241
+ end
242
+ end
243
+
244
+ it "should find the div in firstPopup" do
245
+ @driver.within_window("firstPopup") do
246
+ @driver.find("//*[@id='divInPopupOne']")[0].text.should eql 'This is the text of divInPopupOne'
247
+ end
248
+ end
249
+ it "should find the div in secondPopup" do
250
+ @driver.within_window("secondPopup") do
251
+ @driver.find("//*[@id='divInPopupTwo']")[0].text.should eql 'This is the text of divInPopupTwo'
252
+ end
253
+ end
254
+ it "should find the divs in both popups" do
255
+ @driver.within_window("secondPopup") do
256
+ @driver.find("//*[@id='divInPopupTwo']")[0].text.should eql 'This is the text of divInPopupTwo'
257
+ end
258
+ @driver.within_window("firstPopup") do
259
+ @driver.find("//*[@id='divInPopupOne']")[0].text.should eql 'This is the text of divInPopupOne'
260
+ end
261
+ end
262
+ it "should find the div in the main window after finding a div in a popup" do
263
+ @driver.within_window("secondPopup") do
264
+ @driver.find("//*[@id='divInPopupTwo']")[0].text.should eql 'This is the text of divInPopupTwo'
265
+ end
266
+ @driver.find("//*[@id='divInMainWindow']")[0].text.should eql 'This is the text for divInMainWindow'
267
+ end
268
+ end
269
+ end
270
+
271
+ shared_examples_for "driver with cookies support" do
272
+ describe "#reset!" do
273
+ it "should set and clean cookies" do
274
+ @driver.visit('/get_cookie')
275
+ @driver.body.should_not include('test_cookie')
276
+
277
+ @driver.visit('/set_cookie')
278
+ @driver.body.should include('Cookie set to test_cookie')
279
+
280
+ @driver.visit('/get_cookie')
281
+ @driver.body.should include('test_cookie')
282
+
283
+ @driver.reset!
284
+ @driver.visit('/get_cookie')
285
+ @driver.body.should_not include('test_cookie')
286
+ end
287
+ end
288
+ end
289
+
290
+ shared_examples_for "driver with infinite redirect detection" do
291
+ it "should follow 5 redirects" do
292
+ @driver.visit('/redirect/5/times')
293
+ @driver.body.should include('redirection complete')
294
+ end
295
+
296
+ it "should not follow more than 5 redirects" do
297
+ running do
298
+ @driver.visit('/redirect/6/times')
299
+ end.should raise_error(Capybara::InfiniteRedirectError)
300
+ end
301
+ end
@@ -0,0 +1,3 @@
1
+ This is a jpeg file :) Since it is rendered in the
2
+ view it doesn't actually contain any binary data,
3
+ as that would cause Nokogiri to go mad.
@@ -0,0 +1 @@
1
+ ThisIsTheTestFile
@@ -0,0 +1,43 @@
1
+ var activeRequests = 0;
2
+ $(function() {
3
+ $('#change').text('I changed it');
4
+ $('#drag').draggable();
5
+ $('#drop').droppable({
6
+ drop: function(event, ui) {
7
+ ui.draggable.remove();
8
+ $(this).html('Dropped!');
9
+ }
10
+ });
11
+ $('#clickable').click(function() {
12
+ var link = $(this);
13
+ setTimeout(function() {
14
+ $(link).after('<a id="has-been-clicked" href="#">Has been clicked</a>');
15
+ $(link).after('<input type="submit" value="New Here">');
16
+ $(link).after('<input type="text" id="new_field">');
17
+ $('#change').remove();
18
+ }, 500);
19
+ return false;
20
+ });
21
+ $('#waiter').change(function() {
22
+ activeRequests = 1;
23
+ setTimeout(function() {
24
+ activeRequests = 0;
25
+ }, 500);
26
+ });
27
+ $('#with_focus_event').focus(function() {
28
+ $('body').append('<p id="focus_event_triggered">Focus Event triggered</p>');
29
+ });
30
+ $('#checkbox_with_event').click(function() {
31
+ $('body').append('<p id="checkbox_event_triggered">Checkbox event triggered</p>');
32
+ });
33
+ $('#fire_ajax_request').click(function() {
34
+ $.ajax({url: "/slow_response", context: document.body, success: function() {
35
+ $('body').append('<p id="ajax_request_done">Ajax request done</p>');
36
+ }});
37
+ });
38
+ $('#reload-link').click(function() {
39
+ setTimeout(function() {
40
+ $('#reload-me').replaceWith('<div id="reload-me"><em><a>RELOADED</a></em></div>');
41
+ }, 250)
42
+ });
43
+ });
@@ -0,0 +1,154 @@
1
+ require 'capybara/spec/test_app'
2
+ require 'nokogiri'
3
+
4
+ Dir[File.dirname(__FILE__)+'/session/*'].each { |group| require group }
5
+
6
+ shared_examples_for "session" do
7
+ def extract_results(session)
8
+ YAML.load Nokogiri::HTML(session.body).xpath("//pre[@id='results']").first.text
9
+ end
10
+
11
+ after do
12
+ @session.reset_session!
13
+ end
14
+
15
+ describe '#visit' do
16
+ it "should fetch a response from the driver" do
17
+ @session.visit('/')
18
+ @session.body.should include('Hello world!')
19
+ @session.visit('/foo')
20
+ @session.body.should include('Another World')
21
+ end
22
+ end
23
+
24
+ describe '#body' do
25
+ it "should return the unmodified page body" do
26
+ @session.visit('/')
27
+ @session.body.should include('Hello world!')
28
+ end
29
+ end
30
+
31
+ describe '#html' do
32
+ it "should return the unmodified page body" do
33
+ # html and body should be aliased, but we can't just check for
34
+ # method(:html) == method(:body) because these shared examples get run
35
+ # against the DSL, which uses forwarding methods. So we test behavior.
36
+ @session.visit('/')
37
+ @session.body.should include('Hello world!')
38
+ end
39
+ end
40
+
41
+ describe '#source' do
42
+ it "should return the unmodified page source" do
43
+ @session.visit('/')
44
+ @session.source.should include('Hello world!')
45
+ end
46
+ end
47
+
48
+ describe '#reset_session!' do
49
+ it "removes cookies" do
50
+ @session.visit('/set_cookie')
51
+ @session.visit('/get_cookie')
52
+ @session.body.should include('test_cookie')
53
+
54
+ @session.reset_session!
55
+ @session.visit('/get_cookie')
56
+ @session.body.should_not include('test_cookie')
57
+ end
58
+
59
+ it "resets current host" do
60
+ @session.visit('http://capybara-testapp.heroku.com')
61
+ @session.current_host.should == 'http://capybara-testapp.heroku.com'
62
+
63
+ @session.reset_session!
64
+ @session.current_host.should be_nil
65
+ end
66
+
67
+ it "resets current path" do
68
+ @session.visit('/with_html')
69
+ @session.current_path.should == '/with_html'
70
+
71
+ @session.reset_session!
72
+ @session.current_path.should be_nil
73
+ end
74
+
75
+ it "resets page body" do
76
+ @session.visit('/with_html')
77
+ @session.body.should include('This is a test')
78
+ @session.find('.//h1').text.should include('This is a test')
79
+
80
+ @session.reset_session!
81
+ @session.body.should_not include('This is a test')
82
+ @session.should have_no_selector('.//h1')
83
+ end
84
+ end
85
+
86
+ it_should_behave_like "all"
87
+ it_should_behave_like "first"
88
+ it_should_behave_like "attach_file"
89
+ it_should_behave_like "check"
90
+ it_should_behave_like "choose"
91
+ it_should_behave_like "click_link_or_button"
92
+ it_should_behave_like "click_button"
93
+ it_should_behave_like "click_link"
94
+ it_should_behave_like "fill_in"
95
+ it_should_behave_like "find_button"
96
+ it_should_behave_like "find_field"
97
+ it_should_behave_like "find_link"
98
+ it_should_behave_like "find_by_id"
99
+ it_should_behave_like "find"
100
+ it_should_behave_like "has_content"
101
+ it_should_behave_like "has_css"
102
+ it_should_behave_like "has_css"
103
+ it_should_behave_like "has_selector"
104
+ it_should_behave_like "has_xpath"
105
+ it_should_behave_like "has_link"
106
+ it_should_behave_like "has_button"
107
+ it_should_behave_like "has_field"
108
+ it_should_behave_like "has_select"
109
+ it_should_behave_like "has_table"
110
+ it_should_behave_like "select"
111
+ it_should_behave_like "text"
112
+ it_should_behave_like "uncheck"
113
+ it_should_behave_like "unselect"
114
+ it_should_behave_like "within"
115
+ it_should_behave_like "current_url"
116
+ it_should_behave_like "current_host"
117
+
118
+ it "should encode complex field names, like array[][value]" do
119
+ @session.visit('/form')
120
+ @session.fill_in('address1_city', :with =>'Paris')
121
+ @session.fill_in('address1_street', :with =>'CDG')
122
+ @session.fill_in('address1_street', :with =>'CDG')
123
+ @session.select("France", :from => 'address1_country')
124
+
125
+ @session.fill_in('address2_city', :with => 'Mikolaiv')
126
+ @session.fill_in('address2_street', :with => 'PGS')
127
+ @session.select("Ukraine", :from => 'address2_country')
128
+
129
+ @session.click_button "awesome"
130
+
131
+ addresses=extract_results(@session)["addresses"]
132
+ addresses.should have(2).addresses
133
+
134
+ addresses[0]["street"].should == 'CDG'
135
+ addresses[0]["city"].should == 'Paris'
136
+ addresses[0]["country"].should == 'France'
137
+
138
+ addresses[1]["street"].should == 'PGS'
139
+ addresses[1]["city"].should == 'Mikolaiv'
140
+ addresses[1]["country"].should == 'Ukraine'
141
+ end
142
+
143
+ end
144
+
145
+
146
+ describe Capybara::Session do
147
+ context 'with non-existant driver' do
148
+ it "should raise an error" do
149
+ running {
150
+ Capybara::Session.new(:quox, TestApp).driver
151
+ }.should raise_error(Capybara::DriverNotFoundError)
152
+ end
153
+ end
154
+ end