capybara_minitest_spec 0.2.2 → 1.0.0

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 (75) hide show
  1. data/.rvmrc +1 -1
  2. data/HISTORY.md +0 -0
  3. data/README.md +31 -32
  4. data/Rakefile +2 -2
  5. data/capybara_minitest_spec.gemspec +6 -4
  6. data/lib/capybara_minitest_spec.rb +53 -6
  7. data/lib/capybara_minitest_spec/test_name.rb +67 -0
  8. data/lib/capybara_minitest_spec/version.rb +1 -1
  9. data/spec/capybara_minitest_spec.spec.rb +13 -0
  10. data/spec/capybara_rspec_matchers.spec.rb +580 -0
  11. data/spec/helper.rb +39 -0
  12. data/{test_app → spec/test_app}/test_app.rb +0 -0
  13. data/{test_app → spec/test_app}/views/buttons.erb +0 -0
  14. data/{test_app → spec/test_app}/views/fieldsets.erb +0 -0
  15. data/{test_app → spec/test_app}/views/form.erb +0 -0
  16. data/{test_app → spec/test_app}/views/frame_one.erb +0 -0
  17. data/{test_app → spec/test_app}/views/frame_two.erb +0 -0
  18. data/{test_app → spec/test_app}/views/header_links.erb +0 -0
  19. data/{test_app → spec/test_app}/views/host_links.erb +0 -0
  20. data/{test_app → spec/test_app}/views/popup_one.erb +0 -0
  21. data/{test_app → spec/test_app}/views/popup_two.erb +0 -0
  22. data/{test_app → spec/test_app}/views/postback.erb +0 -0
  23. data/{test_app → spec/test_app}/views/tables.erb +0 -0
  24. data/{test_app → spec/test_app}/views/with_html.erb +0 -0
  25. data/{test_app → spec/test_app}/views/with_html_entities.erb +0 -0
  26. data/{test_app → spec/test_app}/views/with_js.erb +0 -0
  27. data/{test_app → spec/test_app}/views/with_scope.erb +0 -0
  28. data/{test_app → spec/test_app}/views/with_simple_html.erb +0 -0
  29. data/{test_app → spec/test_app}/views/within_frames.erb +0 -0
  30. data/{test_app → spec/test_app}/views/within_popups.erb +0 -0
  31. data/spec/test_name.spec.rb +47 -0
  32. metadata +142 -121
  33. data/lib/capybara_minitest_spec/matcher.rb +0 -126
  34. data/test/capybara_node_matchers_spec.rb +0 -471
  35. data/test/custom_matcher_spec.rb +0 -29
  36. data/test/matcher_spec.rb +0 -45
  37. data/test/spec_helper.rb +0 -14
  38. data/test_app/driver.rb +0 -297
  39. data/test_app/fixtures/capybara.jpg +0 -3
  40. data/test_app/fixtures/test_file.txt +0 -1
  41. data/test_app/public/test.js +0 -43
  42. data/test_app/session.rb +0 -154
  43. data/test_app/session/all_spec.rb +0 -78
  44. data/test_app/session/attach_file_spec.rb +0 -73
  45. data/test_app/session/check_spec.rb +0 -65
  46. data/test_app/session/choose_spec.rb +0 -26
  47. data/test_app/session/click_button_spec.rb +0 -304
  48. data/test_app/session/click_link_or_button_spec.rb +0 -36
  49. data/test_app/session/click_link_spec.rb +0 -119
  50. data/test_app/session/current_host_spec.rb +0 -68
  51. data/test_app/session/current_url_spec.rb +0 -15
  52. data/test_app/session/fill_in_spec.rb +0 -125
  53. data/test_app/session/find_button_spec.rb +0 -18
  54. data/test_app/session/find_by_id_spec.rb +0 -18
  55. data/test_app/session/find_field_spec.rb +0 -26
  56. data/test_app/session/find_link_spec.rb +0 -19
  57. data/test_app/session/find_spec.rb +0 -149
  58. data/test_app/session/first_spec.rb +0 -105
  59. data/test_app/session/has_button_spec.rb +0 -32
  60. data/test_app/session/has_content_spec.rb +0 -106
  61. data/test_app/session/has_css_spec.rb +0 -243
  62. data/test_app/session/has_field_spec.rb +0 -192
  63. data/test_app/session/has_link_spec.rb +0 -37
  64. data/test_app/session/has_select_spec.rb +0 -129
  65. data/test_app/session/has_selector_spec.rb +0 -129
  66. data/test_app/session/has_table_spec.rb +0 -96
  67. data/test_app/session/has_xpath_spec.rb +0 -123
  68. data/test_app/session/headers.rb +0 -19
  69. data/test_app/session/javascript.rb +0 -289
  70. data/test_app/session/response_code.rb +0 -19
  71. data/test_app/session/select_spec.rb +0 -113
  72. data/test_app/session/text_spec.rb +0 -19
  73. data/test_app/session/uncheck_spec.rb +0 -21
  74. data/test_app/session/unselect_spec.rb +0 -61
  75. data/test_app/session/within_spec.rb +0 -178
@@ -1,29 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class Capybara::Session
4
- def has_flash_message?(message)
5
- within '#flash' do
6
- has_content? message
7
- end
8
- end
9
- end
10
- CapybaraMiniTestSpec::Matcher.new(:has_flash_message?)
11
-
12
- describe 'Custom matcher' do
13
- include Capybara::DSL
14
-
15
- before :each do
16
- Capybara.default_selector = :css
17
- visit '/flash_message'
18
- end
19
-
20
- after { Capybara.default_selector = :xpath }
21
-
22
- it 'works with positive expectation' do
23
- page.must_have_flash_message 'Barry Allen'
24
- end
25
-
26
- it 'works with negative expectation' do
27
- page.wont_have_flash_message 'The Blob'
28
- end
29
- end
@@ -1,45 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe CapybaraMiniTestSpec::Matcher do
4
-
5
- let(:matcher) { CapybaraMiniTestSpec::Matcher.new(:has_css?) }
6
-
7
- it 'should define an assertion' do
8
- MiniTest::Assertions.public_instance_methods.must_include(:assert_page_has_css)
9
- end
10
-
11
- it 'should define a refutation' do
12
- MiniTest::Assertions.public_instance_methods.must_include(:refute_page_has_css)
13
- end
14
-
15
- it 'should define positive expectation' do
16
- MiniTest::Expectations.public_instance_methods.must_include(:must_have_css)
17
- end
18
-
19
- it 'should define negative expectation' do
20
- MiniTest::Expectations.public_instance_methods.must_include(:wont_have_css)
21
- end
22
-
23
- it 'should wrap the asserted object in a Capybara::Node::Simple' do
24
- matcher.send(:wrap, '').must_be_instance_of(Capybara::Node::Simple)
25
- end
26
-
27
- it '#test returns true when test passes' do
28
- test_result = matcher.test('<h1>Test</h1>', 'h1', {:count => 1})
29
- end
30
-
31
- it '#test returns false when test fails' do
32
- test_result = matcher.test('<h1>Test</h1>', 'h2', {:count => 1})
33
- end
34
-
35
- it "#failure_message with 'assert' arg returns positive assertion failure message" do
36
- message = CapybaraMiniTestSpec::Matcher.failure_message('assert', :has_css?, {:option => 1})
37
- message.must_equal 'Matcher failed: has_css?({:option=>1})'
38
- end
39
-
40
- it "#failure_message with 'refute' arg returns negative assertion failure message" do
41
- message = CapybaraMiniTestSpec::Matcher.failure_message('refute', :has_css?, {:option => 1})
42
- message.must_equal 'Matcher should have failed: has_css?({:option=>1})'
43
- end
44
-
45
- end
@@ -1,14 +0,0 @@
1
- require 'bundler/setup'
2
-
3
- require 'minitest/autorun'
4
- require 'capybara/dsl'
5
-
6
- require 'capybara_minitest_spec'
7
-
8
- # Make all specs a subclass of MiniTest::Spec.
9
- MiniTest::Spec.register_spec_type //, MiniTest::Spec
10
-
11
- # Setup Rack test app.
12
- $LOAD_PATH << File.join(__FILE__, '../../test_app')
13
- require 'test_app'
14
- Capybara.app = TestApp
@@ -1,297 +0,0 @@
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').first.value.should == 'banana'
68
- end
69
-
70
- it "should allow assignment of field value" do
71
- @driver.find('//input').first.value.should == 'monkey'
72
- @driver.find('//input').first.set('gorilla')
73
- @driver.find('//input').first.value.should == 'gorilla'
74
- end
75
-
76
- it "should extract node tag name" do
77
- @driver.find('//a')[0].tag_name.should == 'a'
78
- @driver.find('//a')[1].tag_name.should == 'a'
79
- @driver.find('//p')[1].tag_name.should == 'p'
80
- end
81
-
82
- it "should extract node visibility" do
83
- @driver.find('//a')[0].should be_visible
84
-
85
- @driver.find('//div[@id="hidden"]')[0].should_not be_visible
86
- @driver.find('//div[@id="hidden_via_ancestor"]')[0].should_not be_visible
87
- end
88
-
89
- it "should extract node checked state" do
90
- @driver.visit('/form')
91
- @driver.find('//input[@id="gender_female"]')[0].should be_checked
92
- @driver.find('//input[@id="gender_male"]')[0].should_not be_checked
93
- @driver.find('//h1')[0].should_not be_checked
94
- end
95
-
96
- it "should extract node selected state" do
97
- @driver.visit('/form')
98
- @driver.find('//option[@value="en"]')[0].should be_selected
99
- @driver.find('//option[@value="sv"]')[0].should_not be_selected
100
- @driver.find('//h1')[0].should_not be_selected
101
- end
102
-
103
- it "should return document text on /html selector" do
104
- @driver.visit('/with_simple_html')
105
- @driver.find('/html')[0].text.should == 'Bar'
106
- end
107
- end
108
- end
109
- end
110
-
111
- shared_examples_for "driver with javascript support" do
112
- before { @driver.visit('/with_js') }
113
-
114
- describe '#find' do
115
- it "should find dynamically changed nodes" do
116
- @driver.find('//p').first.text.should == 'I changed it'
117
- end
118
- end
119
-
120
- describe '#drag_to' do
121
- it "should drag and drop an object" do
122
- draggable = @driver.find('//div[@id="drag"]').first
123
- droppable = @driver.find('//div[@id="drop"]').first
124
- draggable.drag_to(droppable)
125
- @driver.find('//div[contains(., "Dropped!")]').should_not be_empty
126
- end
127
- end
128
-
129
- describe "#evaluate_script" do
130
- it "should return the value of the executed script" do
131
- @driver.evaluate_script('1+1').should == 2
132
- end
133
- end
134
-
135
- end
136
-
137
- shared_examples_for "driver with resynchronization support" do
138
- before { @driver.visit('/with_js') }
139
- describe "#find" do
140
- context "with synchronization turned on" do
141
- before { @driver.options[:resynchronize] = true }
142
- it "should wait for all ajax requests to finish" do
143
- @driver.find('//input[@id="fire_ajax_request"]').first.click
144
- @driver.find('//p[@id="ajax_request_done"]').should_not be_empty
145
- end
146
- end
147
-
148
- context "with resynchronization turned off" do
149
- before { @driver.options[:resynchronize] = false }
150
- it "should not wait for ajax requests to finish" do
151
- @driver.find('//input[@id="fire_ajax_request"]').first.click
152
- @driver.find('//p[@id="ajax_request_done"]').should be_empty
153
- end
154
- end
155
-
156
- context "with short synchronization timeout" do
157
- before { @driver.options[:resynchronize] = true }
158
- before { @driver.options[:resynchronization_timeout] = 0.1 }
159
-
160
- it "should raise an error" do
161
- expect do
162
- @driver.find('//input[@id="fire_ajax_request"]').first.click
163
- end.to raise_error(Capybara::TimeoutError, "failed to resynchronize, ajax request timed out")
164
- end
165
- end
166
- end
167
-
168
- after { @driver.options[:resynchronize] = false }
169
- after { @driver.options[:resynchronization_timeout] = 10 }
170
- end
171
-
172
- shared_examples_for "driver with header support" do
173
- it "should make headers available through response_headers" do
174
- @driver.visit('/with_simple_html')
175
- @driver.response_headers['Content-Type'].should =~ /text\/html/
176
- end
177
- end
178
-
179
- shared_examples_for "driver with status code support" do
180
- it "should make the status code available through status_code" do
181
- @driver.visit('/with_simple_html')
182
- @driver.status_code.should == 200
183
- end
184
- end
185
-
186
- shared_examples_for "driver without status code support" do
187
- it "should raise when trying to access the status code available through status_code" do
188
- @driver.visit('/with_simple_html')
189
- lambda {
190
- @driver.status_code
191
- }.should raise_error(Capybara::NotSupportedByDriverError)
192
- end
193
- end
194
-
195
- shared_examples_for "driver with frame support" do
196
- describe '#within_frame' do
197
- before(:each) do
198
- @driver.visit('/within_frames')
199
- end
200
-
201
- it "should find the div in frameOne" do
202
- @driver.within_frame("frameOne") do
203
- @driver.find("//*[@id='divInFrameOne']")[0].text.should eql 'This is the text of divInFrameOne'
204
- end
205
- end
206
- it "should find the div in FrameTwo" do
207
- @driver.within_frame("frameTwo") do
208
- @driver.find("//*[@id='divInFrameTwo']")[0].text.should eql 'This is the text of divInFrameTwo'
209
- end
210
- end
211
- it "should find the text div in the main window after finding text in frameOne" do
212
- @driver.within_frame("frameOne") do
213
- @driver.find("//*[@id='divInFrameOne']")[0].text.should eql 'This is the text of divInFrameOne'
214
- end
215
- @driver.find("//*[@id='divInMainWindow']")[0].text.should eql 'This is the text for divInMainWindow'
216
- end
217
- it "should find the text div in the main window after finding text in frameTwo" do
218
- @driver.within_frame("frameTwo") do
219
- @driver.find("//*[@id='divInFrameTwo']")[0].text.should eql 'This is the text of divInFrameTwo'
220
- end
221
- @driver.find("//*[@id='divInMainWindow']")[0].text.should eql 'This is the text for divInMainWindow'
222
- end
223
- end
224
- end
225
-
226
- shared_examples_for "driver with support for window switching" do
227
- describe '#within_window' do
228
- before(:each) do
229
- @driver.visit('/within_popups')
230
- end
231
- after(:each) do
232
- @driver.within_window("firstPopup") do
233
- @driver.evaluate_script('window.close()')
234
- end
235
- @driver.within_window("secondPopup") do
236
- @driver.evaluate_script('window.close()')
237
- end
238
- end
239
-
240
- it "should find the div in firstPopup" do
241
- @driver.within_window("firstPopup") do
242
- @driver.find("//*[@id='divInPopupOne']")[0].text.should eql 'This is the text of divInPopupOne'
243
- end
244
- end
245
- it "should find the div in secondPopup" do
246
- @driver.within_window("secondPopup") do
247
- @driver.find("//*[@id='divInPopupTwo']")[0].text.should eql 'This is the text of divInPopupTwo'
248
- end
249
- end
250
- it "should find the divs in both popups" do
251
- @driver.within_window("secondPopup") do
252
- @driver.find("//*[@id='divInPopupTwo']")[0].text.should eql 'This is the text of divInPopupTwo'
253
- end
254
- @driver.within_window("firstPopup") do
255
- @driver.find("//*[@id='divInPopupOne']")[0].text.should eql 'This is the text of divInPopupOne'
256
- end
257
- end
258
- it "should find the div in the main window after finding a div in a popup" do
259
- @driver.within_window("secondPopup") do
260
- @driver.find("//*[@id='divInPopupTwo']")[0].text.should eql 'This is the text of divInPopupTwo'
261
- end
262
- @driver.find("//*[@id='divInMainWindow']")[0].text.should eql 'This is the text for divInMainWindow'
263
- end
264
- end
265
- end
266
-
267
- shared_examples_for "driver with cookies support" do
268
- describe "#reset!" do
269
- it "should set and clean cookies" do
270
- @driver.visit('/get_cookie')
271
- @driver.body.should_not include('test_cookie')
272
-
273
- @driver.visit('/set_cookie')
274
- @driver.body.should include('Cookie set to test_cookie')
275
-
276
- @driver.visit('/get_cookie')
277
- @driver.body.should include('test_cookie')
278
-
279
- @driver.reset!
280
- @driver.visit('/get_cookie')
281
- @driver.body.should_not include('test_cookie')
282
- end
283
- end
284
- end
285
-
286
- shared_examples_for "driver with infinite redirect detection" do
287
- it "should follow 5 redirects" do
288
- @driver.visit('/redirect/5/times')
289
- @driver.body.should include('redirection complete')
290
- end
291
-
292
- it "should not follow more than 5 redirects" do
293
- running do
294
- @driver.visit('/redirect/6/times')
295
- end.should raise_error(Capybara::InfiniteRedirectError)
296
- end
297
- end
@@ -1,3 +0,0 @@
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.
@@ -1 +0,0 @@
1
- ThisIsTheTestFile
@@ -1,43 +0,0 @@
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
- });
@@ -1,154 +0,0 @@
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