capybara 2.9.0 → 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 (87) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +23 -0
  3. data/README.md +37 -30
  4. data/lib/capybara/node/actions.rb +18 -15
  5. data/lib/capybara/node/base.rb +2 -2
  6. data/lib/capybara/node/element.rb +1 -1
  7. data/lib/capybara/node/finders.rb +37 -32
  8. data/lib/capybara/node/matchers.rb +187 -171
  9. data/lib/capybara/queries/match_query.rb +1 -3
  10. data/lib/capybara/queries/selector_query.rb +48 -19
  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/css.rb +30 -0
  16. data/lib/capybara/selector/selector.rb +24 -1
  17. data/lib/capybara/selector.rb +22 -23
  18. data/lib/capybara/session.rb +4 -4
  19. data/lib/capybara/spec/session/accept_alert_spec.rb +4 -4
  20. data/lib/capybara/spec/session/accept_confirm_spec.rb +1 -1
  21. data/lib/capybara/spec/session/accept_prompt_spec.rb +5 -5
  22. data/lib/capybara/spec/session/all_spec.rb +27 -27
  23. data/lib/capybara/spec/session/assert_current_path.rb +2 -2
  24. data/lib/capybara/spec/session/assert_selector.rb +28 -28
  25. data/lib/capybara/spec/session/assert_text.rb +20 -20
  26. data/lib/capybara/spec/session/assert_title.rb +2 -2
  27. data/lib/capybara/spec/session/attach_file_spec.rb +2 -2
  28. data/lib/capybara/spec/session/check_spec.rb +19 -10
  29. data/lib/capybara/spec/session/choose_spec.rb +4 -4
  30. data/lib/capybara/spec/session/click_button_spec.rb +18 -5
  31. data/lib/capybara/spec/session/click_link_or_button_spec.rb +6 -6
  32. data/lib/capybara/spec/session/click_link_spec.rb +13 -13
  33. data/lib/capybara/spec/session/current_url_spec.rb +2 -2
  34. data/lib/capybara/spec/session/dismiss_confirm_spec.rb +1 -1
  35. data/lib/capybara/spec/session/dismiss_prompt_spec.rb +1 -1
  36. data/lib/capybara/spec/session/element/matches_selector_spec.rb +21 -8
  37. data/lib/capybara/spec/session/evaluate_script_spec.rb +1 -1
  38. data/lib/capybara/spec/session/execute_script_spec.rb +2 -2
  39. data/lib/capybara/spec/session/fill_in_spec.rb +30 -30
  40. data/lib/capybara/spec/session/find_button_spec.rb +5 -5
  41. data/lib/capybara/spec/session/find_by_id_spec.rb +2 -2
  42. data/lib/capybara/spec/session/find_field_spec.rb +11 -7
  43. data/lib/capybara/spec/session/find_link_spec.rb +2 -2
  44. data/lib/capybara/spec/session/find_spec.rb +57 -48
  45. data/lib/capybara/spec/session/first_spec.rb +9 -9
  46. data/lib/capybara/spec/session/go_back_spec.rb +1 -1
  47. data/lib/capybara/spec/session/go_forward_spec.rb +1 -1
  48. data/lib/capybara/spec/session/has_button_spec.rb +12 -12
  49. data/lib/capybara/spec/session/has_css_spec.rb +73 -73
  50. data/lib/capybara/spec/session/has_current_path_spec.rb +2 -2
  51. data/lib/capybara/spec/session/has_field_spec.rb +78 -68
  52. data/lib/capybara/spec/session/has_link_spec.rb +8 -8
  53. data/lib/capybara/spec/session/has_select_spec.rb +70 -61
  54. data/lib/capybara/spec/session/has_selector_spec.rb +28 -28
  55. data/lib/capybara/spec/session/has_text_spec.rb +6 -6
  56. data/lib/capybara/spec/session/has_title_spec.rb +2 -2
  57. data/lib/capybara/spec/session/has_xpath_spec.rb +26 -26
  58. data/lib/capybara/spec/session/headers.rb +1 -1
  59. data/lib/capybara/spec/session/html_spec.rb +3 -3
  60. data/lib/capybara/spec/session/node_spec.rb +15 -15
  61. data/lib/capybara/spec/session/reset_session_spec.rb +4 -4
  62. data/lib/capybara/spec/session/response_code.rb +1 -1
  63. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +3 -3
  64. data/lib/capybara/spec/session/screenshot_spec.rb +1 -1
  65. data/lib/capybara/spec/session/select_spec.rb +30 -30
  66. data/lib/capybara/spec/session/selectors_spec.rb +6 -2
  67. data/lib/capybara/spec/session/uncheck_spec.rb +2 -2
  68. data/lib/capybara/spec/session/unselect_spec.rb +14 -14
  69. data/lib/capybara/spec/session/visit_spec.rb +2 -2
  70. data/lib/capybara/spec/session/within_frame_spec.rb +2 -2
  71. data/lib/capybara/spec/session/within_spec.rb +6 -6
  72. data/lib/capybara/spec/spec_helper.rb +1 -1
  73. data/lib/capybara/spec/test_app.rb +1 -1
  74. data/lib/capybara/spec/views/form.erb +6 -3
  75. data/lib/capybara/version.rb +1 -1
  76. data/lib/capybara.rb +2 -2
  77. data/spec/basic_node_spec.rb +5 -5
  78. data/spec/capybara_spec.rb +1 -1
  79. data/spec/dsl_spec.rb +1 -1
  80. data/spec/rack_test_spec.rb +7 -7
  81. data/spec/rspec/matchers_spec.rb +6 -6
  82. data/spec/rspec_spec.rb +1 -1
  83. data/spec/selector_spec.rb +94 -3
  84. data/spec/selenium_firefox_spec.rb +1 -1
  85. data/spec/selenium_spec_chrome.rb +1 -1
  86. data/spec/shared_selenium_session.rb +10 -10
  87. metadata +3 -2
@@ -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
@@ -85,13 +85,13 @@ Capybara::SpecHelper.spec '#current_url, #current_path, #current_host' do
85
85
  should_be_on 0, "/landed"
86
86
  end
87
87
 
88
- it "is affected by pushState", :requires => [:js] do
88
+ it "is affected by pushState", requires: [:js] do
89
89
  @session.visit("/with_js")
90
90
  @session.execute_script("window.history.pushState({}, '', '/pushed')")
91
91
  expect(@session.current_path).to eq("/pushed")
92
92
  end
93
93
 
94
- it "is affected by replaceState", :requires => [:js] do
94
+ it "is affected by replaceState", requires: [:js] do
95
95
  @session.visit("/with_js")
96
96
  @session.execute_script("window.history.replaceState({}, '', '/replaced')")
97
97
  expect(@session.current_path).to eq("/replaced")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- Capybara::SpecHelper.spec '#dismiss_confirm', :requires => [:modals] do
2
+ Capybara::SpecHelper.spec '#dismiss_confirm', requires: [:modals] do
3
3
  before do
4
4
  @session.visit('/with_js')
5
5
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- Capybara::SpecHelper.spec '#dismiss_prompt', :requires => [:modals] do
2
+ Capybara::SpecHelper.spec '#dismiss_prompt', requires: [:modals] do
3
3
  before do
4
4
  @session.visit('/with_js')
5
5
  end
@@ -24,8 +24,8 @@ Capybara::SpecHelper.spec '#match_selector?' do
24
24
 
25
25
  context "with text" do
26
26
  it "should discard all matches where the given string is not contained" do
27
- expect(@element).to match_selector("//span", :text => "42")
28
- expect(@element).not_to match_selector("//span", :text => "Doesnotexist")
27
+ expect(@element).to match_selector("//span", text: "42")
28
+ expect(@element).not_to match_selector("//span", text: "Doesnotexist")
29
29
  end
30
30
  end
31
31
 
@@ -42,6 +42,19 @@ Capybara::SpecHelper.spec '#match_selector?' do
42
42
  expect(@element.matches_xpath?("//span", text: '42')).to be true
43
43
  expect(@element.matches_xpath?("//span", text: 'Nope')).to be false
44
44
  end
45
+
46
+ it 'should accept selector filters' do
47
+ @session.visit('/form')
48
+ cbox = @session.find(:css, '#form_pets_dog')
49
+ expect(cbox.matches_selector?(:checkbox, id: 'form_pets_dog', option: 'dog', name: 'form[pets][]', checked: true)).to be true
50
+ end
51
+
52
+ it 'should accept a custom filter block' do
53
+ @session.visit('/form')
54
+ cbox = @session.find(:css, '#form_pets_dog')
55
+ expect(cbox.matches_selector?(:checkbox){ |node| node[:id] == "form_pets_dog"}).to be true
56
+ expect(cbox.matches_selector?(:checkbox){ |node| node[:id] != "form_pets_dog"}).to be false
57
+ end
45
58
  end
46
59
 
47
60
  Capybara::SpecHelper.spec '#not_matches_selector?' do
@@ -70,22 +83,22 @@ Capybara::SpecHelper.spec '#not_matches_selector?' do
70
83
 
71
84
  context "with text" do
72
85
  it "should discard all matches where the given string is contained" do
73
- expect(@element).not_to not_match_selector(:css, "span.number", :text => "42")
74
- expect(@element).to not_match_selector(:css, "span.number", :text => "Doesnotexist")
86
+ expect(@element).not_to not_match_selector(:css, "span.number", text: "42")
87
+ expect(@element).to not_match_selector(:css, "span.number", text: "Doesnotexist")
75
88
  end
76
89
  end
77
90
 
78
91
  it "should have CSS sugar" do
79
92
  expect(@element.not_matches_css?("span.number")).to be false
80
93
  expect(@element.not_matches_css?("p a#doesnotexist")).to be true
81
- expect(@element.not_matches_css?("span.number", :text => "42")).to be false
82
- expect(@element.not_matches_css?("span.number", :text => "Doesnotexist")).to be true
94
+ expect(@element.not_matches_css?("span.number", text: "42")).to be false
95
+ expect(@element.not_matches_css?("span.number", text: "Doesnotexist")).to be true
83
96
  end
84
97
 
85
98
  it "should have xpath sugar" do
86
99
  expect(@element.not_matches_xpath?("//span")).to be false
87
100
  expect(@element.not_matches_xpath?("//div")).to be true
88
- expect(@element.not_matches_xpath?("//span", :text => "42")).to be false
89
- expect(@element.not_matches_xpath?("//span", :text => "Doesnotexist")).to be true
101
+ expect(@element.not_matches_xpath?("//span", text: "42")).to be false
102
+ expect(@element.not_matches_xpath?("//span", text: "Doesnotexist")).to be true
90
103
  end
91
104
  end if Gem::Version.new(RSpec::Expectations::Version::STRING) >= Gem::Version.new('3.1')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- Capybara::SpecHelper.spec "#evaluate_script", :requires => [:js] do
2
+ Capybara::SpecHelper.spec "#evaluate_script", requires: [:js] do
3
3
  it "should evaluate the given script and return whatever it produces" do
4
4
  @session.visit('/with_js')
5
5
  expect(@session.evaluate_script("1+3")).to eq(4)
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
- Capybara::SpecHelper.spec "#execute_script", :requires => [:js] do
2
+ Capybara::SpecHelper.spec "#execute_script", requires: [:js] do
3
3
  it "should execute the given script and return nothing" do
4
4
  @session.visit('/with_js')
5
5
  expect(@session.execute_script("document.getElementById('change').textContent = 'Funky Doodle'")).to be_nil
6
- expect(@session).to have_css('#change', :text => 'Funky Doodle')
6
+ expect(@session).to have_css('#change', text: 'Funky Doodle')
7
7
  end
8
8
 
9
9
  it "should be able to call functions defined in the page" do
@@ -5,97 +5,97 @@ Capybara::SpecHelper.spec "#fill_in" do
5
5
  end
6
6
 
7
7
  it "should fill in a text field by id" do
8
- @session.fill_in('form_first_name', :with => 'Harry')
8
+ @session.fill_in('form_first_name', with: 'Harry')
9
9
  @session.click_button('awesome')
10
10
  expect(extract_results(@session)['first_name']).to eq('Harry')
11
11
  end
12
12
 
13
13
  it "should fill in a text field by name" do
14
- @session.fill_in('form[last_name]', :with => 'Green')
14
+ @session.fill_in('form[last_name]', with: 'Green')
15
15
  @session.click_button('awesome')
16
16
  expect(extract_results(@session)['last_name']).to eq('Green')
17
17
  end
18
18
 
19
19
  it "should fill in a text field by label without for" do
20
- @session.fill_in('First Name', :with => 'Harry')
20
+ @session.fill_in('First Name', with: 'Harry')
21
21
  @session.click_button('awesome')
22
22
  expect(extract_results(@session)['first_name']).to eq('Harry')
23
23
  end
24
24
 
25
25
  it "should fill in a url field by label without for" do
26
- @session.fill_in('Html5 Url', :with => 'http://www.avenueq.com')
26
+ @session.fill_in('Html5 Url', with: 'http://www.avenueq.com')
27
27
  @session.click_button('html5_submit')
28
28
  expect(extract_results(@session)['html5_url']).to eq('http://www.avenueq.com')
29
29
  end
30
30
 
31
31
  it "should fill in a textarea by id" do
32
- @session.fill_in('form_description', :with => 'Texty text')
32
+ @session.fill_in('form_description', with: 'Texty text')
33
33
  @session.click_button('awesome')
34
34
  expect(extract_results(@session)['description']).to eq('Texty text')
35
35
  end
36
36
 
37
37
  it "should fill in a textarea by label" do
38
- @session.fill_in('Description', :with => 'Texty text')
38
+ @session.fill_in('Description', with: 'Texty text')
39
39
  @session.click_button('awesome')
40
40
  expect(extract_results(@session)['description']).to eq('Texty text')
41
41
  end
42
42
 
43
43
  it "should fill in a textarea by name" do
44
- @session.fill_in('form[description]', :with => 'Texty text')
44
+ @session.fill_in('form[description]', with: 'Texty text')
45
45
  @session.click_button('awesome')
46
46
  expect(extract_results(@session)['description']).to eq('Texty text')
47
47
  end
48
48
 
49
49
  it "should fill in a password field by id" do
50
- @session.fill_in('form_password', :with => 'supasikrit')
50
+ @session.fill_in('form_password', with: 'supasikrit')
51
51
  @session.click_button('awesome')
52
52
  expect(extract_results(@session)['password']).to eq('supasikrit')
53
53
  end
54
54
 
55
55
  it "should handle HTML in a textarea" do
56
- @session.fill_in('form_description', :with => 'is <strong>very</strong> secret!')
56
+ @session.fill_in('form_description', with: 'is <strong>very</strong> secret!')
57
57
  @session.click_button('awesome')
58
58
  expect(extract_results(@session)['description']).to eq('is <strong>very</strong> secret!')
59
59
  end
60
60
 
61
61
  it "should handle newlines in a textarea" do
62
- @session.fill_in('form_description', :with => "\nSome text\n")
62
+ @session.fill_in('form_description', with: "\nSome text\n")
63
63
  @session.click_button('awesome')
64
64
  expect(extract_results(@session)['description']).to eq("\r\nSome text\r\n")
65
65
  end
66
66
 
67
67
  it "should fill in a field with a custom type" do
68
- @session.fill_in('Schmooo', :with => 'Schmooo is the game')
68
+ @session.fill_in('Schmooo', with: 'Schmooo is the game')
69
69
  @session.click_button('awesome')
70
70
  expect(extract_results(@session)['schmooo']).to eq('Schmooo is the game')
71
71
  end
72
72
 
73
73
  it "should fill in a field without a type" do
74
- @session.fill_in('Phone', :with => '+1 555 7022')
74
+ @session.fill_in('Phone', with: '+1 555 7022')
75
75
  @session.click_button('awesome')
76
76
  expect(extract_results(@session)['phone']).to eq('+1 555 7022')
77
77
  end
78
78
 
79
79
  it "should fill in a text field respecting its maxlength attribute" do
80
- @session.fill_in('Zipcode', :with => '52071350')
80
+ @session.fill_in('Zipcode', with: '52071350')
81
81
  @session.click_button('awesome')
82
82
  expect(extract_results(@session)['zipcode']).to eq('52071')
83
83
  end
84
84
 
85
85
  it "should fill in a password field by name" do
86
- @session.fill_in('form[password]', :with => 'supasikrit')
86
+ @session.fill_in('form[password]', with: 'supasikrit')
87
87
  @session.click_button('awesome')
88
88
  expect(extract_results(@session)['password']).to eq('supasikrit')
89
89
  end
90
90
 
91
91
  it "should fill in a password field by label" do
92
- @session.fill_in('Password', :with => 'supasikrit')
92
+ @session.fill_in('Password', with: 'supasikrit')
93
93
  @session.click_button('awesome')
94
94
  expect(extract_results(@session)['password']).to eq('supasikrit')
95
95
  end
96
96
 
97
97
  it "should fill in a password field by name" do
98
- @session.fill_in('form[password]', :with => 'supasikrit')
98
+ @session.fill_in('form[password]', with: 'supasikrit')
99
99
  @session.click_button('awesome')
100
100
  expect(extract_results(@session)['password']).to eq('supasikrit')
101
101
  end
@@ -104,39 +104,39 @@ Capybara::SpecHelper.spec "#fill_in" do
104
104
  expect {@session.fill_in 'Name', 'ignu'}.to raise_error(RuntimeError, /with/)
105
105
  end
106
106
 
107
- it "should wait for asynchronous load", :requires => [:js] do
107
+ it "should wait for asynchronous load", requires: [:js] do
108
108
  @session.visit('/with_js')
109
109
  @session.click_link('Click me')
110
- @session.fill_in('new_field', :with => 'Testing...')
110
+ @session.fill_in('new_field', with: 'Testing...')
111
111
  end
112
112
 
113
113
  it "casts to string" do
114
- @session.fill_in(:'form_first_name', :with => :'Harry')
114
+ @session.fill_in(:'form_first_name', with: :'Harry')
115
115
  @session.click_button('awesome')
116
116
  expect(extract_results(@session)['first_name']).to eq('Harry')
117
117
  end
118
118
 
119
119
  it "casts to string if field has maxlength" do
120
- @session.fill_in(:'form_zipcode', :with => 1234567)
120
+ @session.fill_in(:'form_zipcode', with: 1234567)
121
121
  @session.click_button('awesome')
122
122
  expect(extract_results(@session)['zipcode']).to eq('12345')
123
123
  end
124
124
 
125
- context 'on a pre-populated textfield with a reformatting onchange', :requires => [:js] do
125
+ context 'on a pre-populated textfield with a reformatting onchange', requires: [:js] do
126
126
  it 'should only trigger onchange once' do
127
127
  @session.visit('/with_js')
128
- @session.fill_in('with_change_event', :with => 'some value')
128
+ @session.fill_in('with_change_event', with: 'some value')
129
129
  # click outside the field to trigger the change event
130
130
  @session.find(:css, 'body').click
131
- expect(@session.find(:css, '.change_event_triggered', :match => :one)).to have_text 'some value'
131
+ expect(@session.find(:css, '.change_event_triggered', match: :one)).to have_text 'some value'
132
132
  end
133
133
 
134
134
  it 'should trigger change when clearing field' do
135
135
  @session.visit('/with_js')
136
- @session.fill_in('with_change_event', :with => '')
136
+ @session.fill_in('with_change_event', with: '')
137
137
  # click outside the field to trigger the change event
138
138
  @session.find(:css, 'body').click
139
- expect(@session).to have_selector(:css, '.change_event_triggered', :match => :one)
139
+ expect(@session).to have_selector(:css, '.change_event_triggered', match: :one)
140
140
  end
141
141
  end
142
142
 
@@ -146,7 +146,7 @@ Capybara::SpecHelper.spec "#fill_in" do
146
146
  it "should not find a hidden field" do
147
147
  msg = "Unable to find field \"Super Secret\""
148
148
  expect do
149
- @session.fill_in('Super Secret', :with => '777')
149
+ @session.fill_in('Super Secret', with: '777')
150
150
  end.to raise_error(Capybara::ElementNotFound, msg)
151
151
  end
152
152
  end
@@ -155,7 +155,7 @@ Capybara::SpecHelper.spec "#fill_in" do
155
155
  it "should raise an error" do
156
156
  msg = "Unable to find field \"does not exist\""
157
157
  expect do
158
- @session.fill_in('does not exist', :with => 'Blah blah')
158
+ @session.fill_in('does not exist', with: 'Blah blah')
159
159
  end.to raise_error(Capybara::ElementNotFound, msg)
160
160
  end
161
161
  end
@@ -163,21 +163,21 @@ Capybara::SpecHelper.spec "#fill_in" do
163
163
  context "on a disabled field" do
164
164
  it "should raise an error" do
165
165
  expect do
166
- @session.fill_in('Disabled Text Field', :with => 'Blah blah')
166
+ @session.fill_in('Disabled Text Field', with: 'Blah blah')
167
167
  end.to raise_error(Capybara::ElementNotFound)
168
168
  end
169
169
  end
170
170
 
171
171
  context "with :exact option" do
172
172
  it "should accept partial matches when false" do
173
- @session.fill_in("Explanation", :with => "Dude", :exact => false)
173
+ @session.fill_in("Explanation", with: "Dude", exact: false)
174
174
  @session.click_button("awesome")
175
175
  expect(extract_results(@session)["name_explanation"]).to eq("Dude")
176
176
  end
177
177
 
178
178
  it "should not accept partial matches when true" do
179
179
  expect do
180
- @session.fill_in("Explanation", :with => "Dude", :exact => true)
180
+ @session.fill_in("Explanation", with: "Dude", exact: true)
181
181
  end.to raise_error(Capybara::ElementNotFound)
182
182
  end
183
183
  end
@@ -33,24 +33,24 @@ Capybara::SpecHelper.spec '#find_button' do
33
33
 
34
34
  context "with :exact option" do
35
35
  it "should accept partial matches when false" do
36
- expect(@session.find_button('What an Awesome', :exact => false).value).to eq("awesome")
36
+ expect(@session.find_button('What an Awesome', exact: false).value).to eq("awesome")
37
37
  end
38
38
 
39
39
  it "should not accept partial matches when true" do
40
40
  expect do
41
- @session.find_button('What an Awesome', :exact => true)
41
+ @session.find_button('What an Awesome', exact: true)
42
42
  end.to raise_error(Capybara::ElementNotFound)
43
43
  end
44
44
  end
45
45
 
46
46
  context "with :disabled option" do
47
47
  it "should find disabled buttons when true" do
48
- expect(@session.find_button('Disabled button', :disabled => true).value).to eq("Disabled button")
48
+ expect(@session.find_button('Disabled button', disabled: true).value).to eq("Disabled button")
49
49
  end
50
50
 
51
51
  it "should not find disabled buttons when false" do
52
52
  expect do
53
- @session.find_button('Disabled button', :disabled => false)
53
+ @session.find_button('Disabled button', disabled: false)
54
54
  end.to raise_error(Capybara::ElementNotFound)
55
55
  end
56
56
 
@@ -61,7 +61,7 @@ Capybara::SpecHelper.spec '#find_button' do
61
61
  end
62
62
 
63
63
  it "should find disabled buttons when :all" do
64
- expect(@session.find_button('Disabled button', :disabled => :all).value).to eq("Disabled button")
64
+ expect(@session.find_button('Disabled button', disabled: :all).value).to eq("Disabled button")
65
65
  end
66
66
  end
67
67
 
@@ -20,12 +20,12 @@ Capybara::SpecHelper.spec '#find_by_id' do
20
20
 
21
21
  context "with :visible option" do
22
22
  it "finds invisible elements when `false`" do
23
- expect(@session.find_by_id("hidden_via_ancestor", :visible => false).text(:all)).to match(/with hidden ancestor/)
23
+ expect(@session.find_by_id("hidden_via_ancestor", visible: false).text(:all)).to match(/with hidden ancestor/)
24
24
  end
25
25
 
26
26
  it "finds invisible elements when `false`" do
27
27
  expect do
28
- @session.find_by_id("hidden_via_ancestor", :visible => true)
28
+ @session.find_by_id("hidden_via_ancestor", visible: true)
29
29
  end.to raise_error(Capybara::ElementNotFound)
30
30
  end
31
31
  end
@@ -8,7 +8,6 @@ Capybara::SpecHelper.spec '#find_field' do
8
8
  expect(@session.find_field('Dog').value).to eq('dog')
9
9
  expect(@session.find_field('form_description').text).to eq('Descriptive text goes here')
10
10
  expect(@session.find_field('Region')[:name]).to eq('form[region]')
11
-
12
11
  end
13
12
 
14
13
  context "aria_label attribute with Capybara.enable_aria_label" do
@@ -50,24 +49,24 @@ Capybara::SpecHelper.spec '#find_field' do
50
49
 
51
50
  context "with :exact option" do
52
51
  it "should accept partial matches when false" do
53
- expect(@session.find_field("Explanation", :exact => false)[:name]).to eq("form[name_explanation]")
52
+ expect(@session.find_field("Explanation", exact: false)[:name]).to eq("form[name_explanation]")
54
53
  end
55
54
 
56
55
  it "should not accept partial matches when true" do
57
56
  expect do
58
- @session.find_field("Explanation", :exact => true)
57
+ @session.find_field("Explanation", exact: true)
59
58
  end.to raise_error(Capybara::ElementNotFound)
60
59
  end
61
60
  end
62
61
 
63
62
  context "with :disabled option" do
64
63
  it "should find disabled fields when true" do
65
- expect(@session.find_field("Disabled Checkbox", :disabled => true)[:name]).to eq("form[disabled_checkbox]")
64
+ expect(@session.find_field("Disabled Checkbox", disabled: true)[:name]).to eq("form[disabled_checkbox]")
66
65
  end
67
66
 
68
67
  it "should not find disabled fields when false" do
69
68
  expect do
70
- @session.find_field("Disabled Checkbox", :disabled => false)
69
+ @session.find_field("Disabled Checkbox", disabled: false)
71
70
  end.to raise_error(Capybara::ElementNotFound)
72
71
  end
73
72
 
@@ -78,11 +77,11 @@ Capybara::SpecHelper.spec '#find_field' do
78
77
  end
79
78
 
80
79
  it "should find disabled fields when :all" do
81
- expect(@session.find_field("Disabled Checkbox", :disabled => :all)[:name]).to eq("form[disabled_checkbox]")
80
+ expect(@session.find_field("Disabled Checkbox", disabled: :all)[:name]).to eq("form[disabled_checkbox]")
82
81
  end
83
82
 
84
83
  it "should find enabled fields when :all" do
85
- expect(@session.find_field('Dog', :disabled => :all).value).to eq('dog')
84
+ expect(@session.find_field('Dog', disabled: :all).value).to eq('dog')
86
85
  end
87
86
  end
88
87
 
@@ -107,4 +106,9 @@ Capybara::SpecHelper.spec '#find_field' do
107
106
  expect(@session.find_field(with: 'dog')['id']).to eq "form_pets_dog"
108
107
  end
109
108
  end
109
+
110
+ it "should accept an optional filter block" do
111
+ # this would be better done with the :with option but this is just a test
112
+ expect(@session.find_field('form[pets][]'){ |node| node.value == 'dog' }[:id]).to eq "form_pets_dog"
113
+ end
110
114
  end
@@ -33,12 +33,12 @@ Capybara::SpecHelper.spec '#find_link' do
33
33
 
34
34
  context "with :exact option" do
35
35
  it "should accept partial matches when false" do
36
- expect(@session.find_link('abo', :exact => false).text).to eq("labore")
36
+ expect(@session.find_link('abo', exact: false).text).to eq("labore")
37
37
  end
38
38
 
39
39
  it "should not accept partial matches when true" do
40
40
  expect do
41
- @session.find_link('abo', :exact => true)
41
+ @session.find_link('abo', exact: true)
42
42
  end.to raise_error(Capybara::ElementNotFound)
43
43
  end
44
44
  end