capybara 2.9.2 → 2.10.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 (84) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +10 -1
  3. data/README.md +34 -27
  4. data/lib/capybara.rb +2 -2
  5. data/lib/capybara/node/actions.rb +3 -3
  6. data/lib/capybara/node/base.rb +2 -2
  7. data/lib/capybara/node/element.rb +1 -1
  8. data/lib/capybara/node/finders.rb +37 -32
  9. data/lib/capybara/node/matchers.rb +187 -171
  10. data/lib/capybara/queries/selector_query.rb +11 -14
  11. data/lib/capybara/rack_test/driver.rb +3 -3
  12. data/lib/capybara/rails.rb +1 -1
  13. data/lib/capybara/rspec/features.rb +1 -1
  14. data/lib/capybara/rspec/matchers.rb +31 -22
  15. data/lib/capybara/selector.rb +2 -2
  16. data/lib/capybara/selector/selector.rb +22 -0
  17. data/lib/capybara/session.rb +4 -4
  18. data/lib/capybara/spec/session/accept_alert_spec.rb +4 -4
  19. data/lib/capybara/spec/session/accept_confirm_spec.rb +1 -1
  20. data/lib/capybara/spec/session/accept_prompt_spec.rb +5 -5
  21. data/lib/capybara/spec/session/all_spec.rb +27 -27
  22. data/lib/capybara/spec/session/assert_current_path.rb +2 -2
  23. data/lib/capybara/spec/session/assert_selector.rb +28 -28
  24. data/lib/capybara/spec/session/assert_text.rb +20 -20
  25. data/lib/capybara/spec/session/assert_title.rb +2 -2
  26. data/lib/capybara/spec/session/attach_file_spec.rb +2 -2
  27. data/lib/capybara/spec/session/check_spec.rb +5 -5
  28. data/lib/capybara/spec/session/choose_spec.rb +4 -4
  29. data/lib/capybara/spec/session/click_button_spec.rb +18 -5
  30. data/lib/capybara/spec/session/click_link_or_button_spec.rb +6 -6
  31. data/lib/capybara/spec/session/click_link_spec.rb +13 -13
  32. data/lib/capybara/spec/session/current_url_spec.rb +2 -2
  33. data/lib/capybara/spec/session/dismiss_confirm_spec.rb +1 -1
  34. data/lib/capybara/spec/session/dismiss_prompt_spec.rb +1 -1
  35. data/lib/capybara/spec/session/element/matches_selector_spec.rb +15 -8
  36. data/lib/capybara/spec/session/evaluate_script_spec.rb +1 -1
  37. data/lib/capybara/spec/session/execute_script_spec.rb +2 -2
  38. data/lib/capybara/spec/session/fill_in_spec.rb +30 -30
  39. data/lib/capybara/spec/session/find_button_spec.rb +5 -5
  40. data/lib/capybara/spec/session/find_by_id_spec.rb +2 -2
  41. data/lib/capybara/spec/session/find_field_spec.rb +11 -7
  42. data/lib/capybara/spec/session/find_link_spec.rb +2 -2
  43. data/lib/capybara/spec/session/find_spec.rb +52 -48
  44. data/lib/capybara/spec/session/first_spec.rb +9 -9
  45. data/lib/capybara/spec/session/go_back_spec.rb +1 -1
  46. data/lib/capybara/spec/session/go_forward_spec.rb +1 -1
  47. data/lib/capybara/spec/session/has_button_spec.rb +12 -12
  48. data/lib/capybara/spec/session/has_css_spec.rb +73 -73
  49. data/lib/capybara/spec/session/has_current_path_spec.rb +2 -2
  50. data/lib/capybara/spec/session/has_field_spec.rb +78 -68
  51. data/lib/capybara/spec/session/has_link_spec.rb +8 -8
  52. data/lib/capybara/spec/session/has_select_spec.rb +70 -61
  53. data/lib/capybara/spec/session/has_selector_spec.rb +28 -28
  54. data/lib/capybara/spec/session/has_text_spec.rb +6 -6
  55. data/lib/capybara/spec/session/has_title_spec.rb +2 -2
  56. data/lib/capybara/spec/session/has_xpath_spec.rb +26 -26
  57. data/lib/capybara/spec/session/headers.rb +1 -1
  58. data/lib/capybara/spec/session/html_spec.rb +3 -3
  59. data/lib/capybara/spec/session/node_spec.rb +15 -15
  60. data/lib/capybara/spec/session/reset_session_spec.rb +4 -4
  61. data/lib/capybara/spec/session/response_code.rb +1 -1
  62. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +3 -3
  63. data/lib/capybara/spec/session/screenshot_spec.rb +1 -1
  64. data/lib/capybara/spec/session/select_spec.rb +30 -30
  65. data/lib/capybara/spec/session/uncheck_spec.rb +2 -2
  66. data/lib/capybara/spec/session/unselect_spec.rb +14 -14
  67. data/lib/capybara/spec/session/visit_spec.rb +2 -2
  68. data/lib/capybara/spec/session/within_frame_spec.rb +2 -2
  69. data/lib/capybara/spec/session/within_spec.rb +6 -6
  70. data/lib/capybara/spec/spec_helper.rb +1 -1
  71. data/lib/capybara/spec/test_app.rb +1 -1
  72. data/lib/capybara/spec/views/form.erb +1 -0
  73. data/lib/capybara/version.rb +1 -1
  74. data/spec/basic_node_spec.rb +5 -5
  75. data/spec/capybara_spec.rb +1 -1
  76. data/spec/dsl_spec.rb +1 -1
  77. data/spec/rack_test_spec.rb +7 -7
  78. data/spec/rspec/matchers_spec.rb +6 -6
  79. data/spec/rspec_spec.rb +1 -1
  80. data/spec/selector_spec.rb +13 -0
  81. data/spec/selenium_firefox_spec.rb +1 -1
  82. data/spec/selenium_spec_chrome.rb +1 -1
  83. data/spec/shared_selenium_session.rb +10 -10
  84. metadata +2 -2
@@ -12,7 +12,7 @@ Capybara::SpecHelper.spec '#assert_current_path' do
12
12
  expect { @session.assert_current_path(/w[a-z]{3}_js/) }.not_to raise_error
13
13
  end
14
14
 
15
- it "should wait for current_path", :requires => [:js] do
15
+ it "should wait for current_path", requires: [:js] do
16
16
  @session.click_link("Change page")
17
17
  expect { @session.assert_current_path("/with_html") }.not_to raise_error
18
18
  end
@@ -49,7 +49,7 @@ Capybara::SpecHelper.spec '#assert_no_current_path?' do
49
49
  expect{@session.assert_no_current_path(/monkey/)}.not_to raise_error
50
50
  end
51
51
 
52
- it "should wait for current_path to disappear", :requires => [:js] do
52
+ it "should wait for current_path to disappear", requires: [:js] do
53
53
  @session.click_link("Change page")
54
54
  expect{@session.assert_no_current_path('/with_js')}.not_to raise_error
55
55
  end
@@ -31,41 +31,41 @@ Capybara::SpecHelper.spec '#assert_selector' do
31
31
 
32
32
  context "with count" do
33
33
  it "should be true if the content is on the page the given number of times" do
34
- @session.assert_selector("//p", :count => 3)
35
- @session.assert_selector("//p//a[@id='foo']", :count => 1)
36
- @session.assert_selector("//p[contains(.,'est')]", :count => 1)
34
+ @session.assert_selector("//p", count: 3)
35
+ @session.assert_selector("//p//a[@id='foo']", count: 1)
36
+ @session.assert_selector("//p[contains(.,'est')]", count: 1)
37
37
  end
38
38
 
39
39
  it "should be false if the content is on the page the given number of times" do
40
- expect { @session.assert_selector("//p", :count => 6) }.to raise_error(Capybara::ElementNotFound)
41
- expect { @session.assert_selector("//p//a[@id='foo']", :count => 2) }.to raise_error(Capybara::ElementNotFound)
42
- expect { @session.assert_selector("//p[contains(.,'est')]", :count => 5) }.to raise_error(Capybara::ElementNotFound)
40
+ expect { @session.assert_selector("//p", count: 6) }.to raise_error(Capybara::ElementNotFound)
41
+ expect { @session.assert_selector("//p//a[@id='foo']", count: 2) }.to raise_error(Capybara::ElementNotFound)
42
+ expect { @session.assert_selector("//p[contains(.,'est')]", count: 5) }.to raise_error(Capybara::ElementNotFound)
43
43
  end
44
44
 
45
45
  it "should be false if the content isn't on the page at all" do
46
- expect { @session.assert_selector("//abbr", :count => 2) }.to raise_error(Capybara::ElementNotFound)
47
- expect { @session.assert_selector("//p//a[@id='doesnotexist']", :count => 1) }.to raise_error(Capybara::ElementNotFound)
46
+ expect { @session.assert_selector("//abbr", count: 2) }.to raise_error(Capybara::ElementNotFound)
47
+ expect { @session.assert_selector("//p//a[@id='doesnotexist']", count: 1) }.to raise_error(Capybara::ElementNotFound)
48
48
  end
49
49
  end
50
50
 
51
51
  context "with text" do
52
52
  it "should discard all matches where the given string is not contained" do
53
- @session.assert_selector("//p//a", :text => "Redirect", :count => 1)
54
- expect { @session.assert_selector("//p", :text => "Doesnotexist") }.to raise_error(Capybara::ElementNotFound)
53
+ @session.assert_selector("//p//a", text: "Redirect", count: 1)
54
+ expect { @session.assert_selector("//p", text: "Doesnotexist") }.to raise_error(Capybara::ElementNotFound)
55
55
  end
56
56
 
57
57
  it "should discard all matches where the given regexp is not matched" do
58
- @session.assert_selector("//p//a", :text => /re[dab]i/i, :count => 1)
59
- expect { @session.assert_selector("//p//a", :text => /Red$/) }.to raise_error(Capybara::ElementNotFound)
58
+ @session.assert_selector("//p//a", text: /re[dab]i/i, count: 1)
59
+ expect { @session.assert_selector("//p//a", text: /Red$/) }.to raise_error(Capybara::ElementNotFound)
60
60
  end
61
61
  end
62
62
 
63
- context "with wait", :requires => [:js] do
63
+ context "with wait", requires: [:js] do
64
64
  it "should find element if it appears before given wait duration" do
65
65
  Capybara.using_wait_time(0.1) do
66
66
  @session.visit('/with_js')
67
67
  @session.click_link('Click me')
68
- @session.assert_selector(:css, "a#has-been-clicked", :text => "Has been clicked", :wait => 0.9)
68
+ @session.assert_selector(:css, "a#has-been-clicked", text: "Has been clicked", wait: 0.9)
69
69
  end
70
70
  end
71
71
  end
@@ -109,40 +109,40 @@ Capybara::SpecHelper.spec '#assert_no_selector' do
109
109
 
110
110
  context "with count" do
111
111
  it "should be false if the content is on the page the given number of times" do
112
- expect { @session.assert_no_selector("//p", :count => 3) }.to raise_error(Capybara::ElementNotFound)
113
- expect { @session.assert_no_selector("//p//a[@id='foo']", :count => 1) }.to raise_error(Capybara::ElementNotFound)
114
- expect { @session.assert_no_selector("//p[contains(.,'est')]", :count => 1) }.to raise_error(Capybara::ElementNotFound)
112
+ expect { @session.assert_no_selector("//p", count: 3) }.to raise_error(Capybara::ElementNotFound)
113
+ expect { @session.assert_no_selector("//p//a[@id='foo']", count: 1) }.to raise_error(Capybara::ElementNotFound)
114
+ expect { @session.assert_no_selector("//p[contains(.,'est')]", count: 1) }.to raise_error(Capybara::ElementNotFound)
115
115
  end
116
116
 
117
117
  it "should be true if the content is on the page the wrong number of times" do
118
- @session.assert_no_selector("//p", :count => 6)
119
- @session.assert_no_selector("//p//a[@id='foo']", :count => 2)
120
- @session.assert_no_selector("//p[contains(.,'est')]", :count => 5)
118
+ @session.assert_no_selector("//p", count: 6)
119
+ @session.assert_no_selector("//p//a[@id='foo']", count: 2)
120
+ @session.assert_no_selector("//p[contains(.,'est')]", count: 5)
121
121
  end
122
122
 
123
123
  it "should be true if the content isn't on the page at all" do
124
- @session.assert_no_selector("//abbr", :count => 2)
125
- @session.assert_no_selector("//p//a[@id='doesnotexist']", :count => 1)
124
+ @session.assert_no_selector("//abbr", count: 2)
125
+ @session.assert_no_selector("//p//a[@id='doesnotexist']", count: 1)
126
126
  end
127
127
  end
128
128
 
129
129
  context "with text" do
130
130
  it "should discard all matches where the given string is contained" do
131
- expect { @session.assert_no_selector("//p//a", :text => "Redirect", :count => 1) }.to raise_error(Capybara::ElementNotFound)
132
- @session.assert_no_selector("//p", :text => "Doesnotexist")
131
+ expect { @session.assert_no_selector("//p//a", text: "Redirect", count: 1) }.to raise_error(Capybara::ElementNotFound)
132
+ @session.assert_no_selector("//p", text: "Doesnotexist")
133
133
  end
134
134
 
135
135
  it "should discard all matches where the given regexp is matched" do
136
- expect { @session.assert_no_selector("//p//a", :text => /re[dab]i/i, :count => 1) }.to raise_error(Capybara::ElementNotFound)
137
- @session.assert_no_selector("//p//a", :text => /Red$/)
136
+ expect { @session.assert_no_selector("//p//a", text: /re[dab]i/i, count: 1) }.to raise_error(Capybara::ElementNotFound)
137
+ @session.assert_no_selector("//p//a", text: /Red$/)
138
138
  end
139
139
  end
140
140
 
141
- context "with wait", :requires => [:js] do
141
+ context "with wait", requires: [:js] do
142
142
  it "should not find element if it appears after given wait duration" do
143
143
  @session.visit('/with_js')
144
144
  @session.click_link('Click me')
145
- @session.assert_no_selector(:css, "a#has-been-clicked", :text => "Has been clicked", :wait => 0.1)
145
+ @session.assert_no_selector(:css, "a#has-been-clicked", text: "Has been clicked", wait: 0.1)
146
146
  end
147
147
  end
148
148
  end
@@ -78,7 +78,7 @@ Capybara::SpecHelper.spec '#assert_text' do
78
78
  end.to raise_error(Capybara::ExpectationNotMet)
79
79
  end
80
80
 
81
- it "should wait for text to appear", :requires => [:js] do
81
+ it "should wait for text to appear", requires: [:js] do
82
82
  @session.visit('/with_js')
83
83
  @session.click_link('Click me')
84
84
  expect(@session.assert_text('Has been clicked')).to eq(true)
@@ -98,7 +98,7 @@ Capybara::SpecHelper.spec '#assert_text' do
98
98
  end
99
99
  end
100
100
 
101
- context "with wait", :requires => [:js] do
101
+ context "with wait", requires: [:js] do
102
102
  it "should find element if it appears before given wait duration" do
103
103
  Capybara.using_wait_time(0) do
104
104
  @session.visit('/with_js')
@@ -125,35 +125,35 @@ Capybara::SpecHelper.spec '#assert_text' do
125
125
  end
126
126
 
127
127
  it 'ignores other filters when :count is specified' do
128
- o = {:count => 5,
129
- :minimum => 6,
130
- :maximum => 0,
131
- :between => 0..4}
128
+ o = {count: 5,
129
+ minimum: 6,
130
+ maximum: 0,
131
+ between: 0..4}
132
132
  expect { @session.assert_text('Header', o) }.not_to raise_error
133
133
  end
134
134
  context 'with no :count expectation' do
135
135
  it 'fails if :minimum is not met' do
136
- o = {:minimum => 6,
137
- :maximum => 5,
138
- :between => 2..7}
136
+ o = {minimum: 6,
137
+ maximum: 5,
138
+ between: 2..7}
139
139
  expect { @session.assert_text('Header', o) }.to raise_error(Capybara::ExpectationNotMet)
140
140
  end
141
141
  it 'fails if :maximum is not met' do
142
- o = {:minimum => 0,
143
- :maximum => 0,
144
- :between => 2..7}
142
+ o = {minimum: 0,
143
+ maximum: 0,
144
+ between: 2..7}
145
145
  expect { @session.assert_text('Header', o) }.to raise_error(Capybara::ExpectationNotMet)
146
146
  end
147
147
  it 'fails if :between is not met' do
148
- o = {:minimum => 0,
149
- :maximum => 5,
150
- :between => 0..4}
148
+ o = {minimum: 0,
149
+ maximum: 5,
150
+ between: 0..4}
151
151
  expect { @session.assert_text('Header', o) }.to raise_error(Capybara::ExpectationNotMet)
152
152
  end
153
153
  it 'succeeds if all combineable expectations are met' do
154
- o = {:minimum => 0,
155
- :maximum => 5,
156
- :between => 2..7}
154
+ o = {minimum: 0,
155
+ maximum: 5,
156
+ between: 2..7}
157
157
  expect { @session.assert_text('Header', o) }.not_to raise_error
158
158
  end
159
159
  end
@@ -215,12 +215,12 @@ Capybara::SpecHelper.spec '#assert_no_text' do
215
215
  end
216
216
  end
217
217
 
218
- context "with wait", :requires => [:js] do
218
+ context "with wait", requires: [:js] do
219
219
  it "should not find element if it appears after given wait duration" do
220
220
  @session.visit('/with_js')
221
221
  @session.click_link('Click me')
222
222
  @session.find(:css, '#reload-list').click
223
- @session.find(:css, '#the-list').assert_no_text('Foo Bar', :wait => 0.3)
223
+ @session.find(:css, '#the-list').assert_no_text('Foo Bar', wait: 0.3)
224
224
  end
225
225
  end
226
226
  end
@@ -19,7 +19,7 @@ Capybara::SpecHelper.spec '#assert_title' do
19
19
  end.to raise_error(Capybara::ExpectationNotMet, 'expected "with_js" to match /w[a-z]{10}_js/')
20
20
  end
21
21
 
22
- it "should wait for title", :requires => [:js] do
22
+ it "should wait for title", requires: [:js] do
23
23
  @session.click_link("Change title")
24
24
  expect(@session.assert_title("changed title")).to eq(true)
25
25
  end
@@ -59,7 +59,7 @@ Capybara::SpecHelper.spec '#assert_no_title' do
59
59
  @session.assert_no_title(/monkey/)
60
60
  end
61
61
 
62
- it "should wait for title to disappear", :requires => [:js] do
62
+ it "should wait for title to disappear", requires: [:js] do
63
63
  @session.click_link("Change title")
64
64
  expect(@session.assert_no_title('with_js')).to eq(true)
65
65
  end
@@ -96,14 +96,14 @@ Capybara::SpecHelper.spec "#attach_file" do
96
96
 
97
97
  context "with :exact option" do
98
98
  it "should set a file path by partial label when false" do
99
- @session.attach_file "Imag", __FILE__, :exact => false
99
+ @session.attach_file "Imag", __FILE__, exact: false
100
100
  @session.click_button('awesome')
101
101
  expect(extract_results(@session)['image']).to eq(File.basename(__FILE__))
102
102
  end
103
103
 
104
104
  it "not allow partial matches when true" do
105
105
  expect do
106
- @session.attach_file "Imag", __FILE__, :exact => true
106
+ @session.attach_file "Imag", __FILE__, exact: true
107
107
  end.to raise_error(Capybara::ElementNotFound)
108
108
  end
109
109
  end
@@ -15,7 +15,7 @@ Capybara::SpecHelper.spec "#check" do
15
15
  end
16
16
  end
17
17
 
18
- it "should trigger associated events", :requires => [:js] do
18
+ it "should trigger associated events", requires: [:js] do
19
19
  @session.visit('/with_js')
20
20
  @session.check('checkbox_with_event')
21
21
  expect(@session).to have_css('#checkbox_event_triggered');
@@ -86,28 +86,28 @@ Capybara::SpecHelper.spec "#check" do
86
86
 
87
87
  context "with :exact option" do
88
88
  it "should accept partial matches when false" do
89
- @session.check('Ham', :exact => false)
89
+ @session.check('Ham', exact: false)
90
90
  @session.click_button('awesome')
91
91
  expect(extract_results(@session)['pets']).to include('hamster')
92
92
  end
93
93
 
94
94
  it "should not accept partial matches when true" do
95
95
  expect do
96
- @session.check('Ham', :exact => true)
96
+ @session.check('Ham', exact: true)
97
97
  end.to raise_error(Capybara::ElementNotFound)
98
98
  end
99
99
  end
100
100
 
101
101
  context "with `option` option" do
102
102
  it "can check boxes by their value" do
103
- @session.check('form[pets][]', :option => "cat")
103
+ @session.check('form[pets][]', option: "cat")
104
104
  @session.click_button('awesome')
105
105
  expect(extract_results(@session)['pets']).to include('cat')
106
106
  end
107
107
 
108
108
  it "should raise an error if option not found" do
109
109
  expect do
110
- @session.check('form[pets][]', :option => "elephant")
110
+ @session.check('form[pets][]', option: "elephant")
111
111
  end.to raise_error(Capybara::ElementNotFound)
112
112
  end
113
113
  end
@@ -41,28 +41,28 @@ Capybara::SpecHelper.spec "#choose" do
41
41
 
42
42
  context "with :exact option" do
43
43
  it "should accept partial matches when false" do
44
- @session.choose("Mal", :exact => false)
44
+ @session.choose("Mal", exact: false)
45
45
  @session.click_button('awesome')
46
46
  expect(extract_results(@session)['gender']).to eq('male')
47
47
  end
48
48
 
49
49
  it "should not accept partial matches when true" do
50
50
  expect do
51
- @session.choose("Mal", :exact => true)
51
+ @session.choose("Mal", exact: true)
52
52
  end.to raise_error(Capybara::ElementNotFound)
53
53
  end
54
54
  end
55
55
 
56
56
  context "with `option` option" do
57
57
  it "can check radio buttons by their value" do
58
- @session.choose('form[gender]', :option => "male")
58
+ @session.choose('form[gender]', option: "male")
59
59
  @session.click_button('awesome')
60
60
  expect(extract_results(@session)['gender']).to eq("male")
61
61
  end
62
62
 
63
63
  it "should raise an error if option not found" do
64
64
  expect do
65
- @session.choose('form[gender]', :option => "hermaphrodite")
65
+ @session.choose('form[gender]', option: "hermaphrodite")
66
66
  end.to raise_error(Capybara::ElementNotFound)
67
67
  end
68
68
  end
@@ -4,7 +4,7 @@ Capybara::SpecHelper.spec '#click_button' do
4
4
  @session.visit('/form')
5
5
  end
6
6
 
7
- it "should wait for asynchronous load", :requires => [:js] do
7
+ it "should wait for asynchronous load", requires: [:js] do
8
8
  @session.visit('/with_js')
9
9
  @session.click_link('Click me')
10
10
  @session.click_button('New Here')
@@ -338,6 +338,19 @@ Capybara::SpecHelper.spec '#click_button' do
338
338
  expect(extract_results(@session)['first_name']).to eq('John')
339
339
  end
340
340
  end
341
+
342
+ context "with descendant image alt given on a button defined by <button> tag" do
343
+ it "should submit the associated form" do
344
+ @session.click_button('A horse eating hay')
345
+ expect(extract_results(@session)['first_name']).to eq('John')
346
+ end
347
+
348
+ it "should work with partial matches" do
349
+ @session.click_button('se eating h')
350
+ expect(extract_results(@session)['first_name']).to eq('John')
351
+ end
352
+ end
353
+
341
354
  context "with a locator that doesn't exist" do
342
355
  it "should raise an error" do
343
356
  msg = "Unable to find button \"does not exist\""
@@ -414,8 +427,8 @@ Capybara::SpecHelper.spec '#click_button' do
414
427
  @session.fill_in('address1_city', :with =>'Paris')
415
428
  @session.fill_in('address1_street', :with =>'CDG')
416
429
 
417
- @session.fill_in('address2_city', :with => 'Mikolaiv')
418
- @session.fill_in('address2_street', :with => 'PGS')
430
+ @session.fill_in('address2_city', with: 'Mikolaiv')
431
+ @session.fill_in('address2_street', with: 'PGS')
419
432
 
420
433
  @session.click_button "awesome"
421
434
 
@@ -433,13 +446,13 @@ Capybara::SpecHelper.spec '#click_button' do
433
446
 
434
447
  context "with :exact option" do
435
448
  it "should accept partial matches when false" do
436
- @session.click_button('What an Awesome', :exact => false)
449
+ @session.click_button('What an Awesome', exact: false)
437
450
  expect(extract_results(@session)['first_name']).to eq('John')
438
451
  end
439
452
 
440
453
  it "should not accept partial matches when true" do
441
454
  expect do
442
- @session.click_button('What an Awesome', :exact => true)
455
+ @session.click_button('What an Awesome', exact: true)
443
456
  end.to raise_error(Capybara::ElementNotFound)
444
457
  end
445
458
  end
@@ -24,7 +24,7 @@ Capybara::SpecHelper.spec '#click_link_or_button' do
24
24
  expect(extract_results(@session)['first_name']).to eq('John')
25
25
  end
26
26
 
27
- it "should wait for asynchronous load", :requires => [:js] do
27
+ it "should wait for asynchronous load", requires: [:js] do
28
28
  @session.visit('/with_js')
29
29
  @session.click_link('Click me')
30
30
  @session.click_link_or_button('Has been clicked')
@@ -40,7 +40,7 @@ Capybara::SpecHelper.spec '#click_link_or_button' do
40
40
  context "when `true`" do
41
41
  it "clicks on approximately matching link" do
42
42
  @session.visit('/with_html')
43
- @session.click_link_or_button('abore', :exact => false)
43
+ @session.click_link_or_button('abore', exact: false)
44
44
  expect(@session).to have_content('Bar')
45
45
  end
46
46
 
@@ -56,7 +56,7 @@ Capybara::SpecHelper.spec '#click_link_or_button' do
56
56
  @session.visit('/with_html')
57
57
  msg = "Unable to find link or button \"abore\""
58
58
  expect do
59
- @session.click_link_or_button('abore', :exact => true)
59
+ @session.click_link_or_button('abore', exact: true)
60
60
  end.to raise_error(Capybara::ElementNotFound, msg)
61
61
  end
62
62
 
@@ -65,7 +65,7 @@ Capybara::SpecHelper.spec '#click_link_or_button' do
65
65
  msg = "Unable to find link or button \"awe\""
66
66
 
67
67
  expect do
68
- @session.click_link_or_button('awe', :exact => true)
68
+ @session.click_link_or_button('awe', exact: true)
69
69
  end.to raise_error(Capybara::ElementNotFound, msg)
70
70
  end
71
71
  end
@@ -85,7 +85,7 @@ Capybara::SpecHelper.spec '#click_link_or_button' do
85
85
  it "ignores disabled buttons when false" do
86
86
  @session.visit('/form')
87
87
  expect do
88
- @session.click_link_or_button('Disabled button', :disabled => false)
88
+ @session.click_link_or_button('Disabled button', disabled: false)
89
89
  end.to raise_error(Capybara::ElementNotFound)
90
90
  end
91
91
 
@@ -105,7 +105,7 @@ Capybara::SpecHelper.spec '#click_link_or_button' do
105
105
  it "does nothing when button is disabled" do
106
106
  @session.visit('/form')
107
107
  expect do
108
- @session.click_link_or_button('Disabled button', :disabled => false)
108
+ @session.click_link_or_button('Disabled button', disabled: false)
109
109
  end.to raise_error(Capybara::ElementNotFound)
110
110
  end
111
111
 
@@ -4,7 +4,7 @@ Capybara::SpecHelper.spec '#click_link' do
4
4
  @session.visit('/with_html')
5
5
  end
6
6
 
7
- it "should wait for asynchronous load", :requires => [:js] do
7
+ it "should wait for asynchronous load", requires: [:js] do
8
8
  @session.visit('/with_js')
9
9
  @session.click_link('Click me')
10
10
  @session.click_link('Has been clicked')
@@ -15,7 +15,7 @@ Capybara::SpecHelper.spec '#click_link' do
15
15
  expect(@session).to have_content('Another World')
16
16
  end
17
17
 
18
- it "raises any errors caught inside the server", :requires => [:server] do
18
+ it "raises any errors caught inside the server", requires: [:server] do
19
19
  quietly { @session.visit("/error") }
20
20
  expect do
21
21
  @session.click_link('foo')
@@ -76,34 +76,34 @@ Capybara::SpecHelper.spec '#click_link' do
76
76
 
77
77
  context "with :href option given" do
78
78
  it "should find links with valid href" do
79
- @session.click_link('labore', :href => '/with_simple_html')
79
+ @session.click_link('labore', href: '/with_simple_html')
80
80
  expect(@session).to have_content('Bar')
81
81
  end
82
82
 
83
83
  it "should raise error if link wasn't found" do
84
- expect { @session.click_link('labore', :href => 'invalid_href') }.to raise_error(Capybara::ElementNotFound)
84
+ expect { @session.click_link('labore', href: 'invalid_href') }.to raise_error(Capybara::ElementNotFound)
85
85
  end
86
86
  end
87
87
 
88
88
  context "with a regex :href option given" do
89
89
  it "should find a link matching an all-matching regex pattern" do
90
- @session.click_link('labore', :href => /.+/)
90
+ @session.click_link('labore', href: /.+/)
91
91
  expect(@session).to have_content('Bar')
92
92
  end
93
93
 
94
94
  it "should find a link matching an exact regex pattern" do
95
- @session.click_link('labore', :href => /\/with_simple_html/)
95
+ @session.click_link('labore', href: /\/with_simple_html/)
96
96
  expect(@session).to have_content('Bar')
97
97
  end
98
98
 
99
99
  it "should find a link matching a partial regex pattern" do
100
- @session.click_link('labore', :href => /\/with_simple/)
100
+ @session.click_link('labore', href: /\/with_simple/)
101
101
  expect(@session).to have_content('Bar')
102
102
  end
103
103
 
104
104
  it "should raise an error if no link's href matched the pattern" do
105
- expect { @session.click_link('labore', :href => /invalid_pattern/) }.to raise_error(Capybara::ElementNotFound)
106
- expect { @session.click_link('labore', :href => /.+d+/) }.to raise_error(Capybara::ElementNotFound)
105
+ expect { @session.click_link('labore', href: /invalid_pattern/) }.to raise_error(Capybara::ElementNotFound)
106
+ expect { @session.click_link('labore', href: /.+d+/) }.to raise_error(Capybara::ElementNotFound)
107
107
  end
108
108
  end
109
109
 
@@ -135,7 +135,7 @@ Capybara::SpecHelper.spec '#click_link' do
135
135
  end
136
136
 
137
137
  it "should do nothing on anchor links" do
138
- @session.fill_in("test_field", :with => 'blah')
138
+ @session.fill_in("test_field", with: 'blah')
139
139
  @session.click_link('Normal Anchor')
140
140
  expect(@session.find_field("test_field").value).to eq('blah')
141
141
  @session.click_link('Blank Anchor')
@@ -145,7 +145,7 @@ Capybara::SpecHelper.spec '#click_link' do
145
145
  end
146
146
 
147
147
  it "should do nothing on URL+anchor links for the same page" do
148
- @session.fill_in("test_field", :with => 'blah')
148
+ @session.fill_in("test_field", with: 'blah')
149
149
  @session.click_link('Anchor on same page')
150
150
  expect(@session.find_field("test_field").value).to eq('blah')
151
151
  end
@@ -169,13 +169,13 @@ Capybara::SpecHelper.spec '#click_link' do
169
169
 
170
170
  context "with :exact option" do
171
171
  it "should accept partial matches when false" do
172
- @session.click_link('abo', :exact => false)
172
+ @session.click_link('abo', exact: false)
173
173
  expect(@session).to have_content('Bar')
174
174
  end
175
175
 
176
176
  it "should not accept partial matches when true" do
177
177
  expect do
178
- @session.click_link('abo', :exact => true)
178
+ @session.click_link('abo', exact: true)
179
179
  end.to raise_error(Capybara::ElementNotFound)
180
180
  end
181
181
  end