capybara 2.9.2 → 2.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +10 -1
- data/README.md +34 -27
- data/lib/capybara.rb +2 -2
- data/lib/capybara/node/actions.rb +3 -3
- data/lib/capybara/node/base.rb +2 -2
- data/lib/capybara/node/element.rb +1 -1
- data/lib/capybara/node/finders.rb +37 -32
- data/lib/capybara/node/matchers.rb +187 -171
- data/lib/capybara/queries/selector_query.rb +11 -14
- data/lib/capybara/rack_test/driver.rb +3 -3
- data/lib/capybara/rails.rb +1 -1
- data/lib/capybara/rspec/features.rb +1 -1
- data/lib/capybara/rspec/matchers.rb +31 -22
- data/lib/capybara/selector.rb +2 -2
- data/lib/capybara/selector/selector.rb +22 -0
- data/lib/capybara/session.rb +4 -4
- data/lib/capybara/spec/session/accept_alert_spec.rb +4 -4
- data/lib/capybara/spec/session/accept_confirm_spec.rb +1 -1
- data/lib/capybara/spec/session/accept_prompt_spec.rb +5 -5
- data/lib/capybara/spec/session/all_spec.rb +27 -27
- data/lib/capybara/spec/session/assert_current_path.rb +2 -2
- data/lib/capybara/spec/session/assert_selector.rb +28 -28
- data/lib/capybara/spec/session/assert_text.rb +20 -20
- data/lib/capybara/spec/session/assert_title.rb +2 -2
- data/lib/capybara/spec/session/attach_file_spec.rb +2 -2
- data/lib/capybara/spec/session/check_spec.rb +5 -5
- data/lib/capybara/spec/session/choose_spec.rb +4 -4
- data/lib/capybara/spec/session/click_button_spec.rb +18 -5
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +6 -6
- data/lib/capybara/spec/session/click_link_spec.rb +13 -13
- data/lib/capybara/spec/session/current_url_spec.rb +2 -2
- data/lib/capybara/spec/session/dismiss_confirm_spec.rb +1 -1
- data/lib/capybara/spec/session/dismiss_prompt_spec.rb +1 -1
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +15 -8
- data/lib/capybara/spec/session/evaluate_script_spec.rb +1 -1
- data/lib/capybara/spec/session/execute_script_spec.rb +2 -2
- data/lib/capybara/spec/session/fill_in_spec.rb +30 -30
- data/lib/capybara/spec/session/find_button_spec.rb +5 -5
- data/lib/capybara/spec/session/find_by_id_spec.rb +2 -2
- data/lib/capybara/spec/session/find_field_spec.rb +11 -7
- data/lib/capybara/spec/session/find_link_spec.rb +2 -2
- data/lib/capybara/spec/session/find_spec.rb +52 -48
- data/lib/capybara/spec/session/first_spec.rb +9 -9
- data/lib/capybara/spec/session/go_back_spec.rb +1 -1
- data/lib/capybara/spec/session/go_forward_spec.rb +1 -1
- data/lib/capybara/spec/session/has_button_spec.rb +12 -12
- data/lib/capybara/spec/session/has_css_spec.rb +73 -73
- data/lib/capybara/spec/session/has_current_path_spec.rb +2 -2
- data/lib/capybara/spec/session/has_field_spec.rb +78 -68
- data/lib/capybara/spec/session/has_link_spec.rb +8 -8
- data/lib/capybara/spec/session/has_select_spec.rb +70 -61
- data/lib/capybara/spec/session/has_selector_spec.rb +28 -28
- data/lib/capybara/spec/session/has_text_spec.rb +6 -6
- data/lib/capybara/spec/session/has_title_spec.rb +2 -2
- data/lib/capybara/spec/session/has_xpath_spec.rb +26 -26
- data/lib/capybara/spec/session/headers.rb +1 -1
- data/lib/capybara/spec/session/html_spec.rb +3 -3
- data/lib/capybara/spec/session/node_spec.rb +15 -15
- data/lib/capybara/spec/session/reset_session_spec.rb +4 -4
- data/lib/capybara/spec/session/response_code.rb +1 -1
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +3 -3
- data/lib/capybara/spec/session/screenshot_spec.rb +1 -1
- data/lib/capybara/spec/session/select_spec.rb +30 -30
- data/lib/capybara/spec/session/uncheck_spec.rb +2 -2
- data/lib/capybara/spec/session/unselect_spec.rb +14 -14
- data/lib/capybara/spec/session/visit_spec.rb +2 -2
- data/lib/capybara/spec/session/within_frame_spec.rb +2 -2
- data/lib/capybara/spec/session/within_spec.rb +6 -6
- data/lib/capybara/spec/spec_helper.rb +1 -1
- data/lib/capybara/spec/test_app.rb +1 -1
- data/lib/capybara/spec/views/form.erb +1 -0
- data/lib/capybara/version.rb +1 -1
- data/spec/basic_node_spec.rb +5 -5
- data/spec/capybara_spec.rb +1 -1
- data/spec/dsl_spec.rb +1 -1
- data/spec/rack_test_spec.rb +7 -7
- data/spec/rspec/matchers_spec.rb +6 -6
- data/spec/rspec_spec.rb +1 -1
- data/spec/selector_spec.rb +13 -0
- data/spec/selenium_firefox_spec.rb +1 -1
- data/spec/selenium_spec_chrome.rb +1 -1
- data/spec/shared_selenium_session.rb +10 -10
- metadata +2 -2
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
Capybara::SpecHelper.spec '#response_headers' do
|
3
|
-
it "should return response headers", :
|
3
|
+
it "should return response headers", requires: [:response_headers] do
|
4
4
|
@session.visit('/with_simple_html')
|
5
5
|
expect(@session.response_headers['Content-Type']).to match %r(text/html)
|
6
6
|
end
|
@@ -5,7 +5,7 @@ Capybara::SpecHelper.spec '#html' do
|
|
5
5
|
expect(@session.html).to include('Hello world!')
|
6
6
|
end
|
7
7
|
|
8
|
-
it "should return the current state of the page", :
|
8
|
+
it "should return the current state of the page", requires: [:js] do
|
9
9
|
@session.visit('/with_js')
|
10
10
|
expect(@session.html).to include('I changed it')
|
11
11
|
expect(@session.html).not_to include('This is text')
|
@@ -18,7 +18,7 @@ Capybara::SpecHelper.spec '#source' do
|
|
18
18
|
expect(@session.source).to include('Hello world!')
|
19
19
|
end
|
20
20
|
|
21
|
-
it "should return the current state of the page", :
|
21
|
+
it "should return the current state of the page", requires: [:js] do
|
22
22
|
@session.visit('/with_js')
|
23
23
|
expect(@session.source).to include('I changed it')
|
24
24
|
expect(@session.source).not_to include('This is text')
|
@@ -31,7 +31,7 @@ Capybara::SpecHelper.spec '#body' do
|
|
31
31
|
expect(@session.body).to include('Hello world!')
|
32
32
|
end
|
33
33
|
|
34
|
-
it "should return the current state of the page", :
|
34
|
+
it "should return the current state of the page", requires: [:js] do
|
35
35
|
@session.visit('/with_js')
|
36
36
|
expect(@session.body).to include('I changed it')
|
37
37
|
expect(@session.body).not_to include('This is text')
|
@@ -10,7 +10,7 @@ Capybara::SpecHelper.spec "node" do
|
|
10
10
|
@form = @session.find(:css, '#get-form')
|
11
11
|
expect(@form).to have_field('Middle Name')
|
12
12
|
expect(@form).to have_no_field('Languages')
|
13
|
-
@form.fill_in('Middle Name', :
|
13
|
+
@form.fill_in('Middle Name', with: 'Monkey')
|
14
14
|
@form.click_button('med')
|
15
15
|
expect(extract_results(@session)['middle_name']).to eq('Monkey')
|
16
16
|
end
|
@@ -96,7 +96,7 @@ Capybara::SpecHelper.spec "node" do
|
|
96
96
|
expect(@session.first('//input').value).to eq('gorilla')
|
97
97
|
end
|
98
98
|
|
99
|
-
it "should fill the field even if the caret was not at the end", :
|
99
|
+
it "should fill the field even if the caret was not at the end", requires: [:js] do
|
100
100
|
@session.execute_script("var el = document.getElementById('test_field'); el.focus(); el.setSelectionRange(0, 0);")
|
101
101
|
@session.first('//input').set('')
|
102
102
|
expect(@session.first('//input').value).to eq('')
|
@@ -122,19 +122,19 @@ Capybara::SpecHelper.spec "node" do
|
|
122
122
|
expect(@session.first('//textarea[@readonly]').set('changed')).to raise_error(Capybara::ReadOnlyElementError)
|
123
123
|
end if Capybara::VERSION.to_f > 3.0
|
124
124
|
|
125
|
-
it 'should allow me to change the contents of a contenteditable element', :
|
125
|
+
it 'should allow me to change the contents of a contenteditable element', requires: [:js] do
|
126
126
|
@session.visit('/with_js')
|
127
127
|
@session.find(:css,'#existing_content_editable').set('WYSIWYG')
|
128
128
|
expect(@session.find(:css,'#existing_content_editable').text).to eq('WYSIWYG')
|
129
129
|
end
|
130
130
|
|
131
|
-
it 'should allow me to set the contents of a contenteditable element', :
|
131
|
+
it 'should allow me to set the contents of a contenteditable element', requires: [:js] do
|
132
132
|
@session.visit('/with_js')
|
133
133
|
@session.find(:css,'#blank_content_editable').set('WYSIWYG')
|
134
134
|
expect(@session.find(:css,'#blank_content_editable').text).to eq('WYSIWYG')
|
135
135
|
end
|
136
136
|
|
137
|
-
it 'should allow me to change the contents of a contenteditable elements child', :
|
137
|
+
it 'should allow me to change the contents of a contenteditable elements child', requires: [:js] do
|
138
138
|
pending "Selenium doesn't like editing nested contents"
|
139
139
|
@session.visit('/with_js')
|
140
140
|
@session.find(:css,'#existing_content_editable_child').set('WYSIWYG')
|
@@ -253,7 +253,7 @@ Capybara::SpecHelper.spec "node" do
|
|
253
253
|
end
|
254
254
|
end
|
255
255
|
|
256
|
-
describe "#trigger", :
|
256
|
+
describe "#trigger", requires: [:js, :trigger] do
|
257
257
|
it "should allow triggering of custom JS events" do
|
258
258
|
@session.visit('/with_js')
|
259
259
|
@session.find(:css, '#with_focus_event').trigger(:focus)
|
@@ -261,7 +261,7 @@ Capybara::SpecHelper.spec "node" do
|
|
261
261
|
end
|
262
262
|
end
|
263
263
|
|
264
|
-
describe '#drag_to', :
|
264
|
+
describe '#drag_to', requires: [:js, :drag] do
|
265
265
|
it "should drag and drop an object" do
|
266
266
|
@session.visit('/with_js')
|
267
267
|
element = @session.find('//div[@id="drag"]')
|
@@ -271,12 +271,12 @@ Capybara::SpecHelper.spec "node" do
|
|
271
271
|
end
|
272
272
|
end
|
273
273
|
|
274
|
-
describe '#hover', :
|
274
|
+
describe '#hover', requires: [:hover] do
|
275
275
|
it "should allow hovering on an element" do
|
276
276
|
@session.visit('/with_hover')
|
277
|
-
expect(@session.find(:css,'.hidden_until_hover', :
|
277
|
+
expect(@session.find(:css,'.hidden_until_hover', visible: false)).not_to be_visible
|
278
278
|
@session.find(:css,'.wrapper').hover
|
279
|
-
expect(@session.find(:css, '.hidden_until_hover', :
|
279
|
+
expect(@session.find(:css, '.hidden_until_hover', visible: false)).to be_visible
|
280
280
|
end
|
281
281
|
end
|
282
282
|
|
@@ -287,7 +287,7 @@ Capybara::SpecHelper.spec "node" do
|
|
287
287
|
end
|
288
288
|
end
|
289
289
|
|
290
|
-
describe '#double_click', :
|
290
|
+
describe '#double_click', requires: [:js] do
|
291
291
|
it "should double click an element" do
|
292
292
|
@session.visit('/with_js')
|
293
293
|
@session.find(:css, '#click-test').double_click
|
@@ -295,7 +295,7 @@ Capybara::SpecHelper.spec "node" do
|
|
295
295
|
end
|
296
296
|
end
|
297
297
|
|
298
|
-
describe '#right_click', :
|
298
|
+
describe '#right_click', requires: [:js] do
|
299
299
|
it "should right click an element" do
|
300
300
|
@session.visit('/with_js')
|
301
301
|
@session.find(:css, '#click-test').right_click
|
@@ -329,7 +329,7 @@ Capybara::SpecHelper.spec "node" do
|
|
329
329
|
end
|
330
330
|
end
|
331
331
|
|
332
|
-
describe '#reload', :
|
332
|
+
describe '#reload', requires: [:js] do
|
333
333
|
context "without automatic reload" do
|
334
334
|
before { Capybara.automatic_reload = false }
|
335
335
|
it "should reload the current context of the node" do
|
@@ -409,7 +409,7 @@ Capybara::SpecHelper.spec "node" do
|
|
409
409
|
|
410
410
|
it "should reload nodes with options" do
|
411
411
|
@session.visit('/with_js')
|
412
|
-
node = @session.find(:css, 'em', :
|
412
|
+
node = @session.find(:css, 'em', text: "reloaded")
|
413
413
|
@session.click_link('Reload!')
|
414
414
|
sleep(1)
|
415
415
|
expect(node.text).to eq('has been reloaded')
|
@@ -418,7 +418,7 @@ Capybara::SpecHelper.spec "node" do
|
|
418
418
|
end
|
419
419
|
|
420
420
|
context "when #synchronize raises server errors" do
|
421
|
-
it "sets an explanatory exception as the cause of server exceptions", :
|
421
|
+
it "sets an explanatory exception as the cause of server exceptions", requires: [:server, :js] do
|
422
422
|
skip "This version of ruby doesn't support exception causes" unless Exception.instance_methods.include? :cause
|
423
423
|
quietly { @session.visit("/error") }
|
424
424
|
expect do
|
@@ -53,7 +53,7 @@ Capybara::SpecHelper.spec '#reset_session!' do
|
|
53
53
|
expect(@session).to have_no_selector :xpath, "/html/body/*", wait: false
|
54
54
|
end
|
55
55
|
|
56
|
-
it "raises any standard errors caught inside the server", :
|
56
|
+
it "raises any standard errors caught inside the server", requires: [:server] do
|
57
57
|
quietly { @session.visit("/error") }
|
58
58
|
expect do
|
59
59
|
@session.reset_session!
|
@@ -68,7 +68,7 @@ Capybara::SpecHelper.spec '#reset_session!' do
|
|
68
68
|
Capybara.reuse_server = false
|
69
69
|
end
|
70
70
|
|
71
|
-
it "raises any standard errors caught inside the server during a second session", :
|
71
|
+
it "raises any standard errors caught inside the server during a second session", requires: [:server] do
|
72
72
|
Capybara.using_driver(@session.mode) do
|
73
73
|
Capybara.using_session(:another_session) do
|
74
74
|
@another_session = Capybara.current_session
|
@@ -87,7 +87,7 @@ Capybara::SpecHelper.spec '#reset_session!' do
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
it "raises configured errors caught inside the server", :
|
90
|
+
it "raises configured errors caught inside the server", requires: [:server] do
|
91
91
|
prev_errors = Capybara.server_errors
|
92
92
|
|
93
93
|
Capybara.server_errors = [LoadError]
|
@@ -104,7 +104,7 @@ Capybara::SpecHelper.spec '#reset_session!' do
|
|
104
104
|
Capybara.server_errors = prev_errors
|
105
105
|
end
|
106
106
|
|
107
|
-
it "ignores server errors when `Capybara.raise_server_errors = false`", :
|
107
|
+
it "ignores server errors when `Capybara.raise_server_errors = false`", requires: [:server] do
|
108
108
|
Capybara.raise_server_errors = false
|
109
109
|
quietly { @session.visit("/error") }
|
110
110
|
@session.reset_session!
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
Capybara::SpecHelper.spec '#status_code' do
|
3
|
-
it "should return response codes", :
|
3
|
+
it "should return response codes", requires: [:status_code] do
|
4
4
|
@session.visit('/with_simple_html')
|
5
5
|
expect(@session.status_code).to eq(200)
|
6
6
|
end
|
@@ -6,7 +6,7 @@ Capybara::SpecHelper.spec '#save_and_open_screenshot' do
|
|
6
6
|
@session.visit '/'
|
7
7
|
end
|
8
8
|
|
9
|
-
it 'opens file from the default directory', :
|
9
|
+
it 'opens file from the default directory', requires: [:screenshot] do
|
10
10
|
expected_file_regex = %r{capybara-\d+\.png}
|
11
11
|
allow(@session.driver).to receive(:save_screenshot)
|
12
12
|
allow(Launchy).to receive(:open)
|
@@ -18,7 +18,7 @@ Capybara::SpecHelper.spec '#save_and_open_screenshot' do
|
|
18
18
|
expect(Launchy).to have_received(:open).with(expected_file_regex)
|
19
19
|
end
|
20
20
|
|
21
|
-
it 'opens file from the provided directory', :
|
21
|
+
it 'opens file from the provided directory', requires: [:screenshot] do
|
22
22
|
custom_path = 'screenshots/1.png'
|
23
23
|
allow(@session.driver).to receive(:save_screenshot)
|
24
24
|
allow(Launchy).to receive(:open)
|
@@ -31,7 +31,7 @@ Capybara::SpecHelper.spec '#save_and_open_screenshot' do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
context 'when launchy cannot be required' do
|
34
|
-
it 'prints out a correct warning message', :
|
34
|
+
it 'prints out a correct warning message', requires: [:screenshot] do
|
35
35
|
file_path = File.join(Dir.tmpdir, 'test.png')
|
36
36
|
allow(@session).to receive(:require).with('launchy').and_raise(LoadError)
|
37
37
|
allow(@session).to receive(:warn)
|
@@ -8,7 +8,7 @@ Capybara::SpecHelper.spec "#save_screenshot" do
|
|
8
8
|
@session.visit '/'
|
9
9
|
end
|
10
10
|
|
11
|
-
it "should generate PNG file", :
|
11
|
+
it "should generate PNG file", requires: [:screenshot] do
|
12
12
|
path = @session.save_screenshot image_path
|
13
13
|
|
14
14
|
magic = File.read(image_path, 4)
|
@@ -9,30 +9,30 @@ Capybara::SpecHelper.spec "#select" do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should return value of the selected option" do
|
12
|
-
@session.select("Miss", :
|
12
|
+
@session.select("Miss", from: 'Title')
|
13
13
|
expect(@session.find_field('Title').value).to eq('Miss')
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should allow selecting options where there are inexact matches" do
|
17
|
-
@session.select("Mr", :
|
17
|
+
@session.select("Mr", from: 'Title')
|
18
18
|
expect(@session.find_field('Title').value).to eq('Mr')
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should allow selecting options where they are the only inexact match" do
|
22
|
-
@session.select("Mis", :
|
22
|
+
@session.select("Mis", from: 'Title')
|
23
23
|
expect(@session.find_field('Title').value).to eq('Miss')
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should not allow selecting options where they are the only inexact match if `Capybara.exact_options = true`" do
|
27
27
|
Capybara.exact_options = true
|
28
28
|
expect do
|
29
|
-
@session.select("Mis", :
|
29
|
+
@session.select("Mis", from: 'Title')
|
30
30
|
end.to raise_error(Capybara::ElementNotFound)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should not allow selecting an option if the match is ambiguous" do
|
34
34
|
expect do
|
35
|
-
@session.select("M", :
|
35
|
+
@session.select("M", from: 'Title')
|
36
36
|
end.to raise_error(Capybara::Ambiguous)
|
37
37
|
end
|
38
38
|
|
@@ -41,13 +41,13 @@ Capybara::SpecHelper.spec "#select" do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should select an option from a select box by id" do
|
44
|
-
@session.select("Finish", :
|
44
|
+
@session.select("Finish", from: 'form_locale')
|
45
45
|
@session.click_button('awesome')
|
46
46
|
expect(extract_results(@session)['locale']).to eq('fi')
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should select an option from a select box by label" do
|
50
|
-
@session.select("Finish", :
|
50
|
+
@session.select("Finish", from: 'Locale')
|
51
51
|
@session.click_button('awesome')
|
52
52
|
expect(extract_results(@session)['locale']).to eq('fi')
|
53
53
|
end
|
@@ -59,13 +59,13 @@ Capybara::SpecHelper.spec "#select" do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should escape quotes" do
|
62
|
-
@session.select("John's made-up language", :
|
62
|
+
@session.select("John's made-up language", from: 'Locale')
|
63
63
|
@session.click_button('awesome')
|
64
64
|
expect(extract_results(@session)['locale']).to eq('jo')
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should obey from" do
|
68
|
-
@session.select("Miss", :
|
68
|
+
@session.select("Miss", from: "Other title")
|
69
69
|
@session.click_button('awesome')
|
70
70
|
results = extract_results(@session)
|
71
71
|
expect(results['other_title']).to eq("Miss")
|
@@ -73,13 +73,13 @@ Capybara::SpecHelper.spec "#select" do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
it "show match labels with preceding or trailing whitespace" do
|
76
|
-
@session.select("Lojban", :
|
76
|
+
@session.select("Lojban", from: 'Locale')
|
77
77
|
@session.click_button('awesome')
|
78
78
|
expect(extract_results(@session)['locale']).to eq('jbo')
|
79
79
|
end
|
80
80
|
|
81
81
|
it "casts to string" do
|
82
|
-
@session.select(:"Miss", :
|
82
|
+
@session.select(:"Miss", from: :'Title')
|
83
83
|
expect(@session.find_field('Title').value).to eq('Miss')
|
84
84
|
end
|
85
85
|
|
@@ -87,7 +87,7 @@ Capybara::SpecHelper.spec "#select" do
|
|
87
87
|
it "should raise an error" do
|
88
88
|
msg = "Unable to find select box \"does not exist\""
|
89
89
|
expect do
|
90
|
-
@session.select('foo', :
|
90
|
+
@session.select('foo', from: 'does not exist')
|
91
91
|
end.to raise_error(Capybara::ElementNotFound, msg)
|
92
92
|
end
|
93
93
|
end
|
@@ -96,7 +96,7 @@ Capybara::SpecHelper.spec "#select" do
|
|
96
96
|
it "should raise an error" do
|
97
97
|
msg = "Unable to find option \"Does not Exist\""
|
98
98
|
expect do
|
99
|
-
@session.select('Does not Exist', :
|
99
|
+
@session.select('Does not Exist', from: 'form_locale')
|
100
100
|
end.to raise_error(Capybara::ElementNotFound, msg)
|
101
101
|
end
|
102
102
|
end
|
@@ -104,20 +104,20 @@ Capybara::SpecHelper.spec "#select" do
|
|
104
104
|
context "on a disabled select" do
|
105
105
|
it "should raise an error" do
|
106
106
|
expect do
|
107
|
-
@session.select('Should not see me', :
|
107
|
+
@session.select('Should not see me', from: 'Disabled Select')
|
108
108
|
end.to raise_error(Capybara::ElementNotFound)
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
112
|
context "on a disabled option" do
|
113
113
|
it "should not select" do
|
114
|
-
@session.select('Other', :
|
114
|
+
@session.select('Other', from: 'form_title')
|
115
115
|
expect(@session.find_field('form_title').value).not_to eq 'Other'
|
116
116
|
end
|
117
117
|
|
118
118
|
it "should warn" do
|
119
119
|
expect_any_instance_of(Capybara::Node::Element).to receive(:warn).once
|
120
|
-
@session.select('Other', :
|
120
|
+
@session.select('Other', from: 'form_title')
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
@@ -127,28 +127,28 @@ Capybara::SpecHelper.spec "#select" do
|
|
127
127
|
end
|
128
128
|
|
129
129
|
it "should return value of the selected options" do
|
130
|
-
@session.select("Ruby", :
|
131
|
-
@session.select("Javascript", :
|
130
|
+
@session.select("Ruby", from: 'Language')
|
131
|
+
@session.select("Javascript", from: 'Language')
|
132
132
|
expect(@session.find_field('Language').value).to include('Ruby', 'Javascript')
|
133
133
|
end
|
134
134
|
|
135
135
|
it "should select one option" do
|
136
|
-
@session.select("Ruby", :
|
136
|
+
@session.select("Ruby", from: 'Language')
|
137
137
|
@session.click_button('awesome')
|
138
138
|
expect(extract_results(@session)['languages']).to eq(['Ruby'])
|
139
139
|
end
|
140
140
|
|
141
141
|
it "should select multiple options" do
|
142
|
-
@session.select("Ruby", :
|
143
|
-
@session.select("Javascript", :
|
142
|
+
@session.select("Ruby", from: 'Language')
|
143
|
+
@session.select("Javascript", from: 'Language')
|
144
144
|
@session.click_button('awesome')
|
145
145
|
expect(extract_results(@session)['languages']).to include('Ruby', 'Javascript')
|
146
146
|
end
|
147
147
|
|
148
148
|
it "should remain selected if already selected" do
|
149
|
-
@session.select("Ruby", :
|
150
|
-
@session.select("Javascript", :
|
151
|
-
@session.select("Ruby", :
|
149
|
+
@session.select("Ruby", from: 'Language')
|
150
|
+
@session.select("Javascript", from: 'Language')
|
151
|
+
@session.select("Ruby", from: 'Language')
|
152
152
|
@session.click_button('awesome')
|
153
153
|
expect(extract_results(@session)['languages']).to include('Ruby', 'Javascript')
|
154
154
|
end
|
@@ -161,19 +161,19 @@ Capybara::SpecHelper.spec "#select" do
|
|
161
161
|
context "with :exact option" do
|
162
162
|
context "when `false`" do
|
163
163
|
it "can match select box approximately" do
|
164
|
-
@session.select("Finish", :
|
164
|
+
@session.select("Finish", from: "Loc", exact: false)
|
165
165
|
@session.click_button("awesome")
|
166
166
|
expect(extract_results(@session)["locale"]).to eq("fi")
|
167
167
|
end
|
168
168
|
|
169
169
|
it "can match option approximately" do
|
170
|
-
@session.select("Fin", :
|
170
|
+
@session.select("Fin", from: "Locale", exact: false)
|
171
171
|
@session.click_button("awesome")
|
172
172
|
expect(extract_results(@session)["locale"]).to eq("fi")
|
173
173
|
end
|
174
174
|
|
175
175
|
it "can match option approximately when :from not given" do
|
176
|
-
@session.select("made-up language", :
|
176
|
+
@session.select("made-up language", exact: false)
|
177
177
|
@session.click_button("awesome")
|
178
178
|
expect(extract_results(@session)["locale"]).to eq("jo")
|
179
179
|
end
|
@@ -182,19 +182,19 @@ Capybara::SpecHelper.spec "#select" do
|
|
182
182
|
context "when `true`" do
|
183
183
|
it "can match select box approximately" do
|
184
184
|
expect do
|
185
|
-
@session.select("Finish", :
|
185
|
+
@session.select("Finish", from: "Loc", exact: true)
|
186
186
|
end.to raise_error(Capybara::ElementNotFound)
|
187
187
|
end
|
188
188
|
|
189
189
|
it "can match option approximately" do
|
190
190
|
expect do
|
191
|
-
@session.select("Fin", :
|
191
|
+
@session.select("Fin", from: "Locale", exact: true)
|
192
192
|
end.to raise_error(Capybara::ElementNotFound)
|
193
193
|
end
|
194
194
|
|
195
195
|
it "can match option approximately when :from not given" do
|
196
196
|
expect do
|
197
|
-
@session.select("made-up language", :
|
197
|
+
@session.select("made-up language", exact: true)
|
198
198
|
end.to raise_error(Capybara::ElementNotFound)
|
199
199
|
end
|
200
200
|
end
|
@@ -27,14 +27,14 @@ Capybara::SpecHelper.spec "#uncheck" do
|
|
27
27
|
|
28
28
|
context "with :exact option" do
|
29
29
|
it "should accept partial matches when false" do
|
30
|
-
@session.uncheck('Ham', :
|
30
|
+
@session.uncheck('Ham', exact: false)
|
31
31
|
@session.click_button('awesome')
|
32
32
|
expect(extract_results(@session)['pets']).not_to include('hamster')
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should not accept partial matches when true" do
|
36
36
|
expect do
|
37
|
-
@session.uncheck('Ham', :
|
37
|
+
@session.uncheck('Ham', exact: true)
|
38
38
|
end.to raise_error(Capybara::ElementNotFound)
|
39
39
|
end
|
40
40
|
end
|