capybara 2.9.2 → 2.10.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -7,15 +7,15 @@ Capybara::SpecHelper.spec '#has_link?' do
7
7
  it "should be true if the given link is on the page" do
8
8
  expect(@session).to have_link('foo')
9
9
  expect(@session).to have_link('awesome title')
10
- expect(@session).to have_link('A link', :href => '/with_simple_html')
11
- expect(@session).to have_link(:'A link', :href => :'/with_simple_html')
12
- expect(@session).to have_link('A link', :href => /\/with_simple_html/)
10
+ expect(@session).to have_link('A link', href: '/with_simple_html')
11
+ expect(@session).to have_link(:'A link', href: :'/with_simple_html')
12
+ expect(@session).to have_link('A link', href: /\/with_simple_html/)
13
13
  end
14
14
 
15
15
  it "should be false if the given link is not on the page" do
16
16
  expect(@session).not_to have_link('monkey')
17
- expect(@session).not_to have_link('A link', :href => '/non-existant-href')
18
- expect(@session).not_to have_link('A link', :href => /non-existant/)
17
+ expect(@session).not_to have_link('A link', href: '/non-existant-href')
18
+ expect(@session).not_to have_link('A link', href: /non-existant/)
19
19
  end
20
20
  end
21
21
 
@@ -27,12 +27,12 @@ Capybara::SpecHelper.spec '#has_no_link?' do
27
27
  it "should be false if the given link is on the page" do
28
28
  expect(@session).not_to have_no_link('foo')
29
29
  expect(@session).not_to have_no_link('awesome title')
30
- expect(@session).not_to have_no_link('A link', :href => '/with_simple_html')
30
+ expect(@session).not_to have_no_link('A link', href: '/with_simple_html')
31
31
  end
32
32
 
33
33
  it "should be true if the given link is not on the page" do
34
34
  expect(@session).to have_no_link('monkey')
35
- expect(@session).to have_no_link('A link', :href => '/non-existant-href')
36
- expect(@session).to have_no_link('A link', :href => /\/non-existant-href/)
35
+ expect(@session).to have_no_link('A link', href: '/non-existant-href')
36
+ expect(@session).to have_no_link('A link', href: /\/non-existant-href/)
37
37
  end
38
38
  end
@@ -15,92 +15,92 @@ Capybara::SpecHelper.spec '#has_select?' do
15
15
 
16
16
  context 'with selected value' do
17
17
  it "should be true if a field with the given value is on the page" do
18
- expect(@session).to have_select('form_locale', :selected => 'English')
19
- expect(@session).to have_select('Region', :selected => 'Norway')
20
- expect(@session).to have_select('Underwear', :selected => [
18
+ expect(@session).to have_select('form_locale', selected: 'English')
19
+ expect(@session).to have_select('Region', selected: 'Norway')
20
+ expect(@session).to have_select('Underwear', selected: [
21
21
  'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
22
22
  ])
23
23
  end
24
24
 
25
25
  it "should be false if the given field is not on the page" do
26
- expect(@session).not_to have_select('Locale', :selected => 'Swedish')
27
- expect(@session).not_to have_select('Does not exist', :selected => 'John')
28
- expect(@session).not_to have_select('City', :selected => 'Not there')
29
- expect(@session).not_to have_select('Underwear', :selected => [
26
+ expect(@session).not_to have_select('Locale', selected: 'Swedish')
27
+ expect(@session).not_to have_select('Does not exist', selected: 'John')
28
+ expect(@session).not_to have_select('City', selected: 'Not there')
29
+ expect(@session).not_to have_select('Underwear', selected: [
30
30
  'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns', 'Nonexistant'
31
31
  ])
32
- expect(@session).not_to have_select('Underwear', :selected => [
32
+ expect(@session).not_to have_select('Underwear', selected: [
33
33
  'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
34
34
  ])
35
- expect(@session).not_to have_select('Underwear', :selected => [
35
+ expect(@session).not_to have_select('Underwear', selected: [
36
36
  'Boxerbriefs', 'Briefs','Commando', "Frenchman's Pantalons"
37
37
  ])
38
38
  end
39
39
 
40
40
  it "should be true after the given value is selected" do
41
- @session.select('Swedish', :from => 'Locale')
42
- expect(@session).to have_select('Locale', :selected => 'Swedish')
41
+ @session.select('Swedish', from: 'Locale')
42
+ expect(@session).to have_select('Locale', selected: 'Swedish')
43
43
  end
44
44
 
45
45
  it "should be false after a different value is selected" do
46
- @session.select('Swedish', :from => 'Locale')
47
- expect(@session).not_to have_select('Locale', :selected => 'English')
46
+ @session.select('Swedish', from: 'Locale')
47
+ expect(@session).not_to have_select('Locale', selected: 'English')
48
48
  end
49
49
 
50
50
  it "should be true after the given values are selected" do
51
- @session.select('Boxers', :from => 'Underwear')
52
- expect(@session).to have_select('Underwear', :selected => [
51
+ @session.select('Boxers', from: 'Underwear')
52
+ expect(@session).to have_select('Underwear', selected: [
53
53
  'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
54
54
  ])
55
55
  end
56
56
 
57
57
  it "should be false after one of the values is unselected" do
58
- @session.unselect('Briefs', :from => 'Underwear')
59
- expect(@session).not_to have_select('Underwear', :selected => [
58
+ @session.unselect('Briefs', from: 'Underwear')
59
+ expect(@session).not_to have_select('Underwear', selected: [
60
60
  'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
61
61
  ])
62
62
  end
63
63
 
64
64
  it "should be true even when the selected option invisible, regardless of the select's visibility" do
65
- expect(@session).to have_select('Icecream', :visible => false, :selected => 'Chocolate')
66
- expect(@session).to have_select('Sorbet', :selected => 'Vanilla')
65
+ expect(@session).to have_select('Icecream', visible: false, selected: 'Chocolate')
66
+ expect(@session).to have_select('Sorbet', selected: 'Vanilla')
67
67
  end
68
68
  end
69
69
 
70
70
  context 'with exact options' do
71
71
  it "should be true if a field with the given options is on the page" do
72
- expect(@session).to have_select('Region', :options => ['Norway', 'Sweden', 'Finland'])
73
- expect(@session).to have_select('Tendency', :options => [])
72
+ expect(@session).to have_select('Region', options: ['Norway', 'Sweden', 'Finland'])
73
+ expect(@session).to have_select('Tendency', options: [])
74
74
  end
75
75
 
76
76
  it "should be false if the given field is not on the page" do
77
- expect(@session).not_to have_select('Locale', :options => ['Swedish'])
78
- expect(@session).not_to have_select('Does not exist', :options => ['John'])
79
- expect(@session).not_to have_select('City', :options => ['London', 'Made up city'])
80
- expect(@session).not_to have_select('Region', :options => ['Norway', 'Sweden'])
81
- expect(@session).not_to have_select('Region', :options => ['Norway', 'Norway', 'Norway'])
77
+ expect(@session).not_to have_select('Locale', options: ['Swedish'])
78
+ expect(@session).not_to have_select('Does not exist', options: ['John'])
79
+ expect(@session).not_to have_select('City', options: ['London', 'Made up city'])
80
+ expect(@session).not_to have_select('Region', options: ['Norway', 'Sweden'])
81
+ expect(@session).not_to have_select('Region', options: ['Norway', 'Norway', 'Norway'])
82
82
  end
83
83
 
84
84
  it" should be true even when the options are invisible, if the select itself is invisible" do
85
- expect(@session).to have_select("Icecream", :visible => false, :options => ['Chocolate', 'Vanilla', 'Strawberry'])
85
+ expect(@session).to have_select("Icecream", visible: false, options: ['Chocolate', 'Vanilla', 'Strawberry'])
86
86
  end
87
87
 
88
88
  end
89
89
 
90
90
  context 'with partial options' do
91
91
  it "should be true if a field with the given partial options is on the page" do
92
- expect(@session).to have_select('Region', :with_options => ['Norway', 'Sweden'])
93
- expect(@session).to have_select('City', :with_options => ['London'])
92
+ expect(@session).to have_select('Region', with_options: ['Norway', 'Sweden'])
93
+ expect(@session).to have_select('City', with_options: ['London'])
94
94
  end
95
95
 
96
96
  it "should be false if a field with the given partial options is not on the page" do
97
- expect(@session).not_to have_select('Locale', :with_options => ['Uruguayan'])
98
- expect(@session).not_to have_select('Does not exist', :with_options => ['John'])
99
- expect(@session).not_to have_select('Region', :with_options => ['Norway', 'Sweden', 'Finland', 'Latvia'])
97
+ expect(@session).not_to have_select('Locale', with_options: ['Uruguayan'])
98
+ expect(@session).not_to have_select('Does not exist', with_options: ['John'])
99
+ expect(@session).not_to have_select('Region', with_options: ['Norway', 'Sweden', 'Finland', 'Latvia'])
100
100
  end
101
101
 
102
102
  it" should be true even when the options are invisible, if the select itself is invisible" do
103
- expect(@session).to have_select("Icecream", :visible => false, :with_options => ['Vanilla', 'Strawberry'])
103
+ expect(@session).to have_select("Icecream", visible: false, with_options: ['Vanilla', 'Strawberry'])
104
104
  end
105
105
  end
106
106
 
@@ -121,6 +121,10 @@ Capybara::SpecHelper.spec '#has_select?' do
121
121
  end
122
122
  end
123
123
 
124
+ it "should support locator-less usage" do
125
+ expect(@session.has_select?(with_options: ['Norway', 'Sweden'])).to eq true
126
+ expect(@session).to have_select(with_options: ['London'] )
127
+ end
124
128
  end
125
129
 
126
130
  Capybara::SpecHelper.spec '#has_no_select?' do
@@ -138,48 +142,48 @@ Capybara::SpecHelper.spec '#has_no_select?' do
138
142
 
139
143
  context 'with selected value' do
140
144
  it "should be false if a field with the given value is on the page" do
141
- expect(@session).not_to have_no_select('form_locale', :selected => 'English')
142
- expect(@session).not_to have_no_select('Region', :selected => 'Norway')
143
- expect(@session).not_to have_no_select('Underwear', :selected => [
145
+ expect(@session).not_to have_no_select('form_locale', selected: 'English')
146
+ expect(@session).not_to have_no_select('Region', selected: 'Norway')
147
+ expect(@session).not_to have_no_select('Underwear', selected: [
144
148
  'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
145
149
  ])
146
150
  end
147
151
 
148
152
  it "should be true if the given field is not on the page" do
149
- expect(@session).to have_no_select('Locale', :selected => 'Swedish')
150
- expect(@session).to have_no_select('Does not exist', :selected => 'John')
151
- expect(@session).to have_no_select('City', :selected => 'Not there')
152
- expect(@session).to have_no_select('Underwear', :selected => [
153
+ expect(@session).to have_no_select('Locale', selected: 'Swedish')
154
+ expect(@session).to have_no_select('Does not exist', selected: 'John')
155
+ expect(@session).to have_no_select('City', selected: 'Not there')
156
+ expect(@session).to have_no_select('Underwear', selected: [
153
157
  'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns', 'Nonexistant'
154
158
  ])
155
- expect(@session).to have_no_select('Underwear', :selected => [
159
+ expect(@session).to have_no_select('Underwear', selected: [
156
160
  'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
157
161
  ])
158
- expect(@session).to have_no_select('Underwear', :selected => [
162
+ expect(@session).to have_no_select('Underwear', selected: [
159
163
  'Boxerbriefs', 'Briefs','Commando', "Frenchman's Pantalons"
160
164
  ])
161
165
  end
162
166
 
163
167
  it "should be false after the given value is selected" do
164
- @session.select('Swedish', :from => 'Locale')
165
- expect(@session).not_to have_no_select('Locale', :selected => 'Swedish')
168
+ @session.select('Swedish', from: 'Locale')
169
+ expect(@session).not_to have_no_select('Locale', selected: 'Swedish')
166
170
  end
167
171
 
168
172
  it "should be true after a different value is selected" do
169
- @session.select('Swedish', :from => 'Locale')
170
- expect(@session).to have_no_select('Locale', :selected => 'English')
173
+ @session.select('Swedish', from: 'Locale')
174
+ expect(@session).to have_no_select('Locale', selected: 'English')
171
175
  end
172
176
 
173
177
  it "should be false after the given values are selected" do
174
- @session.select('Boxers', :from => 'Underwear')
175
- expect(@session).not_to have_no_select('Underwear', :selected => [
178
+ @session.select('Boxers', from: 'Underwear')
179
+ expect(@session).not_to have_no_select('Underwear', selected: [
176
180
  'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
177
181
  ])
178
182
  end
179
183
 
180
184
  it "should be true after one of the values is unselected" do
181
- @session.unselect('Briefs', :from => 'Underwear')
182
- expect(@session).to have_no_select('Underwear', :selected => [
185
+ @session.unselect('Briefs', from: 'Underwear')
186
+ expect(@session).to have_no_select('Underwear', selected: [
183
187
  'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
184
188
  ])
185
189
  end
@@ -187,28 +191,33 @@ Capybara::SpecHelper.spec '#has_no_select?' do
187
191
 
188
192
  context 'with exact options' do
189
193
  it "should be false if a field with the given options is on the page" do
190
- expect(@session).not_to have_no_select('Region', :options => ['Norway', 'Sweden', 'Finland'])
194
+ expect(@session).not_to have_no_select('Region', options: ['Norway', 'Sweden', 'Finland'])
191
195
  end
192
196
 
193
197
  it "should be true if the given field is not on the page" do
194
- expect(@session).to have_no_select('Locale', :options => ['Swedish'])
195
- expect(@session).to have_no_select('Does not exist', :options => ['John'])
196
- expect(@session).to have_no_select('City', :options => ['London', 'Made up city'])
197
- expect(@session).to have_no_select('Region', :options => ['Norway', 'Sweden'])
198
- expect(@session).to have_no_select('Region', :options => ['Norway', 'Norway', 'Norway'])
198
+ expect(@session).to have_no_select('Locale', options: ['Swedish'])
199
+ expect(@session).to have_no_select('Does not exist', options: ['John'])
200
+ expect(@session).to have_no_select('City', options: ['London', 'Made up city'])
201
+ expect(@session).to have_no_select('Region', options: ['Norway', 'Sweden'])
202
+ expect(@session).to have_no_select('Region', options: ['Norway', 'Norway', 'Norway'])
199
203
  end
200
204
  end
201
205
 
202
206
  context 'with partial options' do
203
207
  it "should be false if a field with the given partial options is on the page" do
204
- expect(@session).not_to have_no_select('Region', :with_options => ['Norway', 'Sweden'])
205
- expect(@session).not_to have_no_select('City', :with_options => ['London'])
208
+ expect(@session).not_to have_no_select('Region', with_options: ['Norway', 'Sweden'])
209
+ expect(@session).not_to have_no_select('City', with_options: ['London'])
206
210
  end
207
211
 
208
212
  it "should be true if a field with the given partial options is not on the page" do
209
- expect(@session).to have_no_select('Locale', :with_options => ['Uruguayan'])
210
- expect(@session).to have_no_select('Does not exist', :with_options => ['John'])
211
- expect(@session).to have_no_select('Region', :with_options => ['Norway', 'Sweden', 'Finland', 'Latvia'])
213
+ expect(@session).to have_no_select('Locale', with_options: ['Uruguayan'])
214
+ expect(@session).to have_no_select('Does not exist', with_options: ['John'])
215
+ expect(@session).to have_no_select('Region', with_options: ['Norway', 'Sweden', 'Finland', 'Latvia'])
212
216
  end
213
217
  end
218
+
219
+ it "should support locator-less usage" do
220
+ expect(@session.has_no_select?(with_options: ['Norway', 'Sweden', 'Finland', 'Latvia'])).to eq true
221
+ expect(@session).to have_no_select(with_options: ['New London'] )
222
+ end
214
223
  end
@@ -31,41 +31,41 @@ Capybara::SpecHelper.spec '#has_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
- expect(@session).to have_selector("//p", :count => 3)
35
- expect(@session).to have_selector("//p//a[@id='foo']", :count => 1)
36
- expect(@session).to have_selector("//p[contains(.,'est')]", :count => 1)
34
+ expect(@session).to have_selector("//p", count: 3)
35
+ expect(@session).to have_selector("//p//a[@id='foo']", count: 1)
36
+ expect(@session).to have_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).not_to have_selector("//p", :count => 6)
41
- expect(@session).not_to have_selector("//p//a[@id='foo']", :count => 2)
42
- expect(@session).not_to have_selector("//p[contains(.,'est')]", :count => 5)
40
+ expect(@session).not_to have_selector("//p", count: 6)
41
+ expect(@session).not_to have_selector("//p//a[@id='foo']", count: 2)
42
+ expect(@session).not_to have_selector("//p[contains(.,'est')]", count: 5)
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).not_to have_selector("//abbr", :count => 2)
47
- expect(@session).not_to have_selector("//p//a[@id='doesnotexist']", :count => 1)
46
+ expect(@session).not_to have_selector("//abbr", count: 2)
47
+ expect(@session).not_to have_selector("//p//a[@id='doesnotexist']", count: 1)
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
- expect(@session).to have_selector("//p//a", :text => "Redirect", :count => 1)
54
- expect(@session).not_to have_selector("//p", :text => "Doesnotexist")
53
+ expect(@session).to have_selector("//p//a", text: "Redirect", count: 1)
54
+ expect(@session).not_to have_selector("//p", text: "Doesnotexist")
55
55
  end
56
56
 
57
57
  it "should respect visibility setting" do
58
- expect(@session).to have_selector(:id, "hidden-text", :text => "Some of this text is hidden!", :visible => false)
59
- expect(@session).not_to have_selector(:id, "hidden-text", :text => "Some of this text is hidden!", :visible => true)
58
+ expect(@session).to have_selector(:id, "hidden-text", text: "Some of this text is hidden!", visible: false)
59
+ expect(@session).not_to have_selector(:id, "hidden-text", text: "Some of this text is hidden!", visible: true)
60
60
  Capybara.ignore_hidden_elements = false
61
- expect(@session).to have_selector(:id, "hidden-text", :text => "Some of this text is hidden!", :visible => false)
61
+ expect(@session).to have_selector(:id, "hidden-text", text: "Some of this text is hidden!", visible: false)
62
62
  Capybara.visible_text_only = true
63
- expect(@session).not_to have_selector(:id, "hidden-text", :text => "Some of this text is hidden!", :visible => true)
63
+ expect(@session).not_to have_selector(:id, "hidden-text", text: "Some of this text is hidden!", visible: true)
64
64
  end
65
65
 
66
66
  it "should discard all matches where the given regexp is not matched" do
67
- expect(@session).to have_selector("//p//a", :text => /re[dab]i/i, :count => 1)
68
- expect(@session).not_to have_selector("//p//a", :text => /Red$/)
67
+ expect(@session).to have_selector("//p//a", text: /re[dab]i/i, count: 1)
68
+ expect(@session).not_to have_selector("//p//a", text: /Red$/)
69
69
  end
70
70
 
71
71
  it "should warn when extra parameters passed" do
@@ -107,32 +107,32 @@ Capybara::SpecHelper.spec '#has_no_selector?' do
107
107
 
108
108
  context "with count" do
109
109
  it "should be false if the content is on the page the given number of times" do
110
- expect(@session).not_to have_no_selector("//p", :count => 3)
111
- expect(@session).not_to have_no_selector("//p//a[@id='foo']", :count => 1)
112
- expect(@session).not_to have_no_selector("//p[contains(.,'est')]", :count => 1)
110
+ expect(@session).not_to have_no_selector("//p", count: 3)
111
+ expect(@session).not_to have_no_selector("//p//a[@id='foo']", count: 1)
112
+ expect(@session).not_to have_no_selector("//p[contains(.,'est')]", count: 1)
113
113
  end
114
114
 
115
115
  it "should be true if the content is on the page the wrong number of times" do
116
- expect(@session).to have_no_selector("//p", :count => 6)
117
- expect(@session).to have_no_selector("//p//a[@id='foo']", :count => 2)
118
- expect(@session).to have_no_selector("//p[contains(.,'est')]", :count => 5)
116
+ expect(@session).to have_no_selector("//p", count: 6)
117
+ expect(@session).to have_no_selector("//p//a[@id='foo']", count: 2)
118
+ expect(@session).to have_no_selector("//p[contains(.,'est')]", count: 5)
119
119
  end
120
120
 
121
121
  it "should be true if the content isn't on the page at all" do
122
- expect(@session).to have_no_selector("//abbr", :count => 2)
123
- expect(@session).to have_no_selector("//p//a[@id='doesnotexist']", :count => 1)
122
+ expect(@session).to have_no_selector("//abbr", count: 2)
123
+ expect(@session).to have_no_selector("//p//a[@id='doesnotexist']", count: 1)
124
124
  end
125
125
  end
126
126
 
127
127
  context "with text" do
128
128
  it "should discard all matches where the given string is contained" do
129
- expect(@session).not_to have_no_selector("//p//a", :text => "Redirect", :count => 1)
130
- expect(@session).to have_no_selector("//p", :text => "Doesnotexist")
129
+ expect(@session).not_to have_no_selector("//p//a", text: "Redirect", count: 1)
130
+ expect(@session).to have_no_selector("//p", text: "Doesnotexist")
131
131
  end
132
132
 
133
133
  it "should discard all matches where the given regexp is matched" do
134
- expect(@session).not_to have_no_selector("//p//a", :text => /re[dab]i/i, :count => 1)
135
- expect(@session).to have_no_selector("//p//a", :text => /Red$/)
134
+ expect(@session).not_to have_no_selector("//p//a", text: /re[dab]i/i, count: 1)
135
+ expect(@session).to have_no_selector("//p//a", text: /Red$/)
136
136
  end
137
137
  end
138
138
  end
@@ -112,7 +112,7 @@ Capybara::SpecHelper.spec '#has_text?' do
112
112
  expect(@session).to have_text(nil)
113
113
  end
114
114
 
115
- it "should wait for text to appear", :requires => [:js] do
115
+ it "should wait for text to appear", requires: [:js] do
116
116
  @session.visit('/with_js')
117
117
  @session.click_link('Click me')
118
118
  expect(@session).to have_text("Has been clicked")
@@ -192,12 +192,12 @@ Capybara::SpecHelper.spec '#has_text?' do
192
192
  end
193
193
  end
194
194
 
195
- context "with wait", :requires => [:js] do
195
+ context "with wait", requires: [:js] do
196
196
  it "should find element if it appears before given wait duration" do
197
197
  Capybara.using_wait_time(0.1) do
198
198
  @session.visit('/with_js')
199
199
  @session.click_link('Click me')
200
- expect(@session).to have_text('Has been clicked', :wait => 0.9)
200
+ expect(@session).to have_text('Has been clicked', wait: 0.9)
201
201
  end
202
202
  end
203
203
  end
@@ -301,17 +301,17 @@ Capybara::SpecHelper.spec '#has_no_text?' do
301
301
  expect(@session).to have_no_text('.orem')
302
302
  end
303
303
 
304
- it "should wait for text to disappear", :requires => [:js] do
304
+ it "should wait for text to disappear", requires: [:js] do
305
305
  @session.visit('/with_js')
306
306
  @session.click_link('Click me')
307
307
  expect(@session).to have_no_text("I changed it")
308
308
  end
309
309
 
310
- context "with wait", :requires => [:js] do
310
+ context "with wait", requires: [:js] do
311
311
  it "should not find element if it appears after given wait duration" do
312
312
  @session.visit('/with_js')
313
313
  @session.click_link('Click me')
314
- expect(@session).to have_no_text('Has been clicked', :wait => 0.1)
314
+ expect(@session).to have_no_text('Has been clicked', wait: 0.1)
315
315
  end
316
316
  end
317
317
  end
@@ -13,7 +13,7 @@ Capybara::SpecHelper.spec '#has_title?' do
13
13
  expect(@session).not_to have_title(/monkey/)
14
14
  end
15
15
 
16
- it "should wait for title", :requires => [:js] do
16
+ it "should wait for title", requires: [:js] do
17
17
  @session.click_link("Change title")
18
18
  expect(@session).to have_title("changed title")
19
19
  end
@@ -37,7 +37,7 @@ Capybara::SpecHelper.spec '#has_no_title?' do
37
37
  expect(@session).to have_no_title(/monkey/)
38
38
  end
39
39
 
40
- it "should wait for title to disappear", :requires => [:js] do
40
+ it "should wait for title to disappear", requires: [:js] do
41
41
  @session.click_link("Change title")
42
42
  expect(@session).to have_no_title('with_js')
43
43
  end
@@ -28,7 +28,7 @@ Capybara::SpecHelper.spec '#has_xpath?' do
28
28
  end
29
29
  end
30
30
 
31
- it "should wait for content to appear", :requires => [:js] do
31
+ it "should wait for content to appear", requires: [:js] do
32
32
  @session.visit('/with_js')
33
33
  @session.click_link('Click me')
34
34
  expect(@session).to have_xpath("//input[@type='submit' and @value='New Here']")
@@ -36,29 +36,29 @@ Capybara::SpecHelper.spec '#has_xpath?' do
36
36
 
37
37
  context "with count" do
38
38
  it "should be true if the content occurs the given number of times" do
39
- expect(@session).to have_xpath("//p", :count => 3)
40
- expect(@session).to have_xpath("//p//a[@id='foo']", :count => 1)
41
- expect(@session).to have_xpath("//p[contains(.,'est')]", :count => 1)
42
- expect(@session).to have_xpath("//p//a[@id='doesnotexist']", :count => 0)
39
+ expect(@session).to have_xpath("//p", count: 3)
40
+ expect(@session).to have_xpath("//p//a[@id='foo']", count: 1)
41
+ expect(@session).to have_xpath("//p[contains(.,'est')]", count: 1)
42
+ expect(@session).to have_xpath("//p//a[@id='doesnotexist']", count: 0)
43
43
  end
44
44
 
45
45
  it "should be false if the content occurs a different number of times than the given" do
46
- expect(@session).not_to have_xpath("//p", :count => 6)
47
- expect(@session).not_to have_xpath("//p//a[@id='foo']", :count => 2)
48
- expect(@session).not_to have_xpath("//p[contains(.,'est')]", :count => 5)
49
- expect(@session).not_to have_xpath("//p//a[@id='doesnotexist']", :count => 1)
46
+ expect(@session).not_to have_xpath("//p", count: 6)
47
+ expect(@session).not_to have_xpath("//p//a[@id='foo']", count: 2)
48
+ expect(@session).not_to have_xpath("//p[contains(.,'est')]", count: 5)
49
+ expect(@session).not_to have_xpath("//p//a[@id='doesnotexist']", count: 1)
50
50
  end
51
51
  end
52
52
 
53
53
  context "with text" do
54
54
  it "should discard all matches where the given string is not contained" do
55
- expect(@session).to have_xpath("//p//a", :text => "Redirect", :count => 1)
56
- expect(@session).not_to have_xpath("//p", :text => "Doesnotexist")
55
+ expect(@session).to have_xpath("//p//a", text: "Redirect", count: 1)
56
+ expect(@session).not_to have_xpath("//p", text: "Doesnotexist")
57
57
  end
58
58
 
59
59
  it "should discard all matches where the given regexp is not matched" do
60
- expect(@session).to have_xpath("//p//a", :text => /re[dab]i/i, :count => 1)
61
- expect(@session).not_to have_xpath("//p//a", :text => /Red$/)
60
+ expect(@session).to have_xpath("//p//a", text: /re[dab]i/i, count: 1)
61
+ expect(@session).not_to have_xpath("//p//a", text: /Red$/)
62
62
  end
63
63
  end
64
64
  end
@@ -92,7 +92,7 @@ Capybara::SpecHelper.spec '#has_no_xpath?' do
92
92
  end
93
93
  end
94
94
 
95
- it "should wait for content to disappear", :requires => [:js] do
95
+ it "should wait for content to disappear", requires: [:js] do
96
96
  @session.visit('/with_js')
97
97
  @session.click_link('Click me')
98
98
  expect(@session).to have_no_xpath("//p[@id='change']")
@@ -100,29 +100,29 @@ Capybara::SpecHelper.spec '#has_no_xpath?' do
100
100
 
101
101
  context "with count" do
102
102
  it "should be false if the content occurs the given number of times" do
103
- expect(@session).not_to have_no_xpath("//p", :count => 3)
104
- expect(@session).not_to have_no_xpath("//p//a[@id='foo']", :count => 1)
105
- expect(@session).not_to have_no_xpath("//p[contains(.,'est')]", :count => 1)
106
- expect(@session).not_to have_no_xpath("//p//a[@id='doesnotexist']", :count => 0)
103
+ expect(@session).not_to have_no_xpath("//p", count: 3)
104
+ expect(@session).not_to have_no_xpath("//p//a[@id='foo']", count: 1)
105
+ expect(@session).not_to have_no_xpath("//p[contains(.,'est')]", count: 1)
106
+ expect(@session).not_to have_no_xpath("//p//a[@id='doesnotexist']", count: 0)
107
107
  end
108
108
 
109
109
  it "should be true if the content occurs a different number of times than the given" do
110
- expect(@session).to have_no_xpath("//p", :count => 6)
111
- expect(@session).to have_no_xpath("//p//a[@id='foo']", :count => 2)
112
- expect(@session).to have_no_xpath("//p[contains(.,'est')]", :count => 5)
113
- expect(@session).to have_no_xpath("//p//a[@id='doesnotexist']", :count => 1)
110
+ expect(@session).to have_no_xpath("//p", count: 6)
111
+ expect(@session).to have_no_xpath("//p//a[@id='foo']", count: 2)
112
+ expect(@session).to have_no_xpath("//p[contains(.,'est')]", count: 5)
113
+ expect(@session).to have_no_xpath("//p//a[@id='doesnotexist']", count: 1)
114
114
  end
115
115
  end
116
116
 
117
117
  context "with text" do
118
118
  it "should discard all matches where the given string is contained" do
119
- expect(@session).not_to have_no_xpath("//p//a", :text => "Redirect", :count => 1)
120
- expect(@session).to have_no_xpath("//p", :text => "Doesnotexist")
119
+ expect(@session).not_to have_no_xpath("//p//a", text: "Redirect", count: 1)
120
+ expect(@session).to have_no_xpath("//p", text: "Doesnotexist")
121
121
  end
122
122
 
123
123
  it "should discard all matches where the given regexp is matched" do
124
- expect(@session).not_to have_no_xpath("//p//a", :text => /re[dab]i/i, :count => 1)
125
- expect(@session).to have_no_xpath("//p//a", :text => /Red$/)
124
+ expect(@session).not_to have_no_xpath("//p//a", text: /re[dab]i/i, count: 1)
125
+ expect(@session).to have_no_xpath("//p//a", text: /Red$/)
126
126
  end
127
127
  end
128
128
  end