capybara 3.3.1 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +16 -0
  3. data/README.md +5 -7
  4. data/lib/capybara.rb +7 -6
  5. data/lib/capybara/config.rb +1 -1
  6. data/lib/capybara/dsl.rb +2 -2
  7. data/lib/capybara/helpers.rb +3 -3
  8. data/lib/capybara/minitest/spec.rb +3 -3
  9. data/lib/capybara/node/actions.rb +18 -18
  10. data/lib/capybara/node/base.rb +1 -1
  11. data/lib/capybara/node/element.rb +2 -2
  12. data/lib/capybara/node/finders.rb +6 -6
  13. data/lib/capybara/node/matchers.rb +5 -5
  14. data/lib/capybara/node/simple.rb +2 -2
  15. data/lib/capybara/queries/ancestor_query.rb +1 -1
  16. data/lib/capybara/queries/base_query.rb +12 -11
  17. data/lib/capybara/queries/current_path_query.rb +1 -1
  18. data/lib/capybara/queries/selector_query.rb +39 -15
  19. data/lib/capybara/queries/sibling_query.rb +1 -1
  20. data/lib/capybara/queries/text_query.rb +1 -1
  21. data/lib/capybara/rack_test/browser.rb +7 -7
  22. data/lib/capybara/rack_test/driver.rb +1 -1
  23. data/lib/capybara/rack_test/form.rb +7 -7
  24. data/lib/capybara/rack_test/node.rb +16 -16
  25. data/lib/capybara/rails.rb +1 -1
  26. data/lib/capybara/result.rb +8 -4
  27. data/lib/capybara/rspec/features.rb +4 -4
  28. data/lib/capybara/rspec/matchers.rb +6 -6
  29. data/lib/capybara/selector.rb +106 -90
  30. data/lib/capybara/selector/css.rb +4 -4
  31. data/lib/capybara/selector/filter_set.rb +52 -8
  32. data/lib/capybara/selector/selector.rb +39 -15
  33. data/lib/capybara/selenium/driver.rb +10 -10
  34. data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +8 -0
  35. data/lib/capybara/selenium/node.rb +9 -10
  36. data/lib/capybara/selenium/nodes/chrome_node.rb +18 -0
  37. data/lib/capybara/selenium/nodes/marionette_node.rb +32 -7
  38. data/lib/capybara/server.rb +3 -3
  39. data/lib/capybara/server/animation_disabler.rb +1 -1
  40. data/lib/capybara/server/middleware.rb +1 -1
  41. data/lib/capybara/session.rb +23 -19
  42. data/lib/capybara/session/config.rb +18 -3
  43. data/lib/capybara/spec/public/test.js +1 -1
  44. data/lib/capybara/spec/session/accept_alert_spec.rb +10 -10
  45. data/lib/capybara/spec/session/accept_confirm_spec.rb +3 -3
  46. data/lib/capybara/spec/session/accept_prompt_spec.rb +9 -10
  47. data/lib/capybara/spec/session/all_spec.rb +33 -32
  48. data/lib/capybara/spec/session/ancestor_spec.rb +19 -19
  49. data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +38 -38
  50. data/lib/capybara/spec/session/assert_current_path_spec.rb +16 -16
  51. data/lib/capybara/spec/session/assert_selector_spec.rb +53 -53
  52. data/lib/capybara/spec/session/assert_style_spec.rb +3 -3
  53. data/lib/capybara/spec/session/assert_text_spec.rb +31 -30
  54. data/lib/capybara/spec/session/assert_title_spec.rb +12 -12
  55. data/lib/capybara/spec/session/attach_file_spec.rb +51 -52
  56. data/lib/capybara/spec/session/body_spec.rb +6 -6
  57. data/lib/capybara/spec/session/check_spec.rb +52 -47
  58. data/lib/capybara/spec/session/choose_spec.rb +32 -32
  59. data/lib/capybara/spec/session/click_button_spec.rb +103 -103
  60. data/lib/capybara/spec/session/click_link_or_button_spec.rb +24 -23
  61. data/lib/capybara/spec/session/click_link_spec.rb +49 -48
  62. data/lib/capybara/spec/session/current_scope_spec.rb +7 -7
  63. data/lib/capybara/spec/session/current_url_spec.rb +26 -27
  64. data/lib/capybara/spec/session/dismiss_confirm_spec.rb +3 -3
  65. data/lib/capybara/spec/session/dismiss_prompt_spec.rb +2 -2
  66. data/lib/capybara/spec/session/element/assert_match_selector_spec.rb +8 -8
  67. data/lib/capybara/spec/session/element/match_css_spec.rb +10 -10
  68. data/lib/capybara/spec/session/element/match_xpath_spec.rb +6 -6
  69. data/lib/capybara/spec/session/element/matches_selector_spec.rb +51 -51
  70. data/lib/capybara/spec/session/evaluate_async_script_spec.rb +7 -7
  71. data/lib/capybara/spec/session/evaluate_script_spec.rb +15 -8
  72. data/lib/capybara/spec/session/execute_script_spec.rb +7 -7
  73. data/lib/capybara/spec/session/fill_in_spec.rb +43 -42
  74. data/lib/capybara/spec/session/find_button_spec.rb +23 -23
  75. data/lib/capybara/spec/session/find_by_id_spec.rb +7 -7
  76. data/lib/capybara/spec/session/find_field_spec.rb +32 -30
  77. data/lib/capybara/spec/session/find_link_spec.rb +21 -21
  78. data/lib/capybara/spec/session/find_spec.rb +153 -135
  79. data/lib/capybara/spec/session/first_spec.rb +41 -41
  80. data/lib/capybara/spec/session/frame/frame_title_spec.rb +5 -5
  81. data/lib/capybara/spec/session/frame/frame_url_spec.rb +5 -5
  82. data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +17 -17
  83. data/lib/capybara/spec/session/frame/within_frame_spec.rb +31 -17
  84. data/lib/capybara/spec/session/go_back_spec.rb +1 -1
  85. data/lib/capybara/spec/session/go_forward_spec.rb +1 -1
  86. data/lib/capybara/spec/session/has_all_selectors_spec.rb +17 -17
  87. data/lib/capybara/spec/session/has_button_spec.rb +13 -13
  88. data/lib/capybara/spec/session/has_css_spec.rb +133 -131
  89. data/lib/capybara/spec/session/has_current_path_spec.rb +29 -29
  90. data/lib/capybara/spec/session/has_field_spec.rb +58 -58
  91. data/lib/capybara/spec/session/has_link_spec.rb +4 -4
  92. data/lib/capybara/spec/session/has_none_selectors_spec.rb +24 -24
  93. data/lib/capybara/spec/session/has_select_spec.rb +43 -43
  94. data/lib/capybara/spec/session/has_selector_spec.rb +71 -71
  95. data/lib/capybara/spec/session/has_style_spec.rb +3 -3
  96. data/lib/capybara/spec/session/has_table_spec.rb +4 -4
  97. data/lib/capybara/spec/session/has_text_spec.rb +53 -52
  98. data/lib/capybara/spec/session/has_title_spec.rb +14 -14
  99. data/lib/capybara/spec/session/has_xpath_spec.rb +39 -38
  100. data/lib/capybara/spec/session/headers_spec.rb +1 -1
  101. data/lib/capybara/spec/session/html_spec.rb +6 -6
  102. data/lib/capybara/spec/session/node_spec.rb +129 -123
  103. data/lib/capybara/spec/session/node_wrapper_spec.rb +10 -7
  104. data/lib/capybara/spec/session/refresh_spec.rb +4 -7
  105. data/lib/capybara/spec/session/reset_session_spec.rb +28 -28
  106. data/lib/capybara/spec/session/response_code_spec.rb +1 -1
  107. data/lib/capybara/spec/session/save_and_open_page_spec.rb +2 -2
  108. data/lib/capybara/spec/session/save_page_spec.rb +37 -37
  109. data/lib/capybara/spec/session/save_screenshot_spec.rb +6 -6
  110. data/lib/capybara/spec/session/screenshot_spec.rb +2 -2
  111. data/lib/capybara/spec/session/select_spec.rb +81 -81
  112. data/lib/capybara/spec/session/selectors_spec.rb +17 -17
  113. data/lib/capybara/spec/session/sibling_spec.rb +9 -9
  114. data/lib/capybara/spec/session/text_spec.rb +23 -23
  115. data/lib/capybara/spec/session/title_spec.rb +5 -5
  116. data/lib/capybara/spec/session/uncheck_spec.rb +24 -20
  117. data/lib/capybara/spec/session/unselect_spec.rb +37 -37
  118. data/lib/capybara/spec/session/visit_spec.rb +48 -49
  119. data/lib/capybara/spec/session/window/current_window_spec.rb +1 -1
  120. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +16 -16
  121. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +2 -2
  122. data/lib/capybara/spec/session/window/window_spec.rb +4 -4
  123. data/lib/capybara/spec/session/window/within_window_spec.rb +14 -14
  124. data/lib/capybara/spec/session/within_spec.rb +41 -41
  125. data/lib/capybara/spec/spec_helper.rb +11 -9
  126. data/lib/capybara/spec/test_app.rb +18 -17
  127. data/lib/capybara/spec/views/form.erb +29 -31
  128. data/lib/capybara/spec/views/with_html.erb +2 -2
  129. data/lib/capybara/version.rb +1 -1
  130. data/spec/basic_node_spec.rb +23 -23
  131. data/spec/capybara_spec.rb +20 -20
  132. data/spec/css_splitter_spec.rb +7 -7
  133. data/spec/dsl_spec.rb +37 -32
  134. data/spec/filter_set_spec.rb +4 -4
  135. data/spec/fixtures/selenium_driver_rspec_failure.rb +1 -1
  136. data/spec/fixtures/selenium_driver_rspec_success.rb +1 -1
  137. data/spec/minitest_spec.rb +4 -4
  138. data/spec/minitest_spec_spec.rb +23 -23
  139. data/spec/per_session_config_spec.rb +5 -5
  140. data/spec/rack_test_spec.rb +44 -44
  141. data/spec/result_spec.rb +14 -14
  142. data/spec/rspec/features_spec.rb +13 -13
  143. data/spec/rspec/scenarios_spec.rb +4 -4
  144. data/spec/rspec/shared_spec_matchers.rb +282 -281
  145. data/spec/rspec/views_spec.rb +3 -3
  146. data/spec/rspec_matchers_spec.rb +10 -10
  147. data/spec/rspec_spec.rb +29 -29
  148. data/spec/selector_spec.rb +64 -64
  149. data/spec/selenium_spec_chrome.rb +14 -22
  150. data/spec/selenium_spec_chrome_remote.rb +28 -8
  151. data/spec/selenium_spec_edge.rb +9 -4
  152. data/spec/selenium_spec_firefox_remote.rb +87 -0
  153. data/spec/selenium_spec_ie.rb +9 -4
  154. data/spec/selenium_spec_marionette.rb +42 -18
  155. data/spec/server_spec.rb +29 -27
  156. data/spec/session_spec.rb +17 -17
  157. data/spec/shared_selenium_session.rb +70 -52
  158. data/spec/spec_helper.rb +1 -1
  159. metadata +4 -2
@@ -3,19 +3,19 @@
3
3
  Capybara::SpecHelper.spec '#has_select?' do
4
4
  before { @session.visit('/form') }
5
5
 
6
- it "should be true if the field is on the page" do
6
+ it 'should be true if the field is on the page' do
7
7
  expect(@session).to have_select('Locale')
8
8
  expect(@session).to have_select('form_region')
9
9
  expect(@session).to have_select('Languages')
10
10
  expect(@session).to have_select(:Languages)
11
11
  end
12
12
 
13
- it "should be false if the field is not on the page" do
13
+ it 'should be false if the field is not on the page' do
14
14
  expect(@session).not_to have_select('Monkey')
15
15
  end
16
16
 
17
17
  context 'with selected value' do
18
- it "should be true if a field with the given value is on the page" do
18
+ it 'should be true if a field with the given value is on the page' do
19
19
  expect(@session).to have_select('form_locale', selected: 'English')
20
20
  expect(@session).to have_select('Region', selected: 'Norway')
21
21
  expect(@session).to have_select('Underwear', selected: [
@@ -23,7 +23,7 @@ Capybara::SpecHelper.spec '#has_select?' do
23
23
  ])
24
24
  end
25
25
 
26
- it "should be false if the given field is not on the page" do
26
+ it 'should be false if the given field is not on the page' do
27
27
  expect(@session).not_to have_select('Locale', selected: 'Swedish')
28
28
  expect(@session).not_to have_select('Does not exist', selected: 'John')
29
29
  expect(@session).not_to have_select('City', selected: 'Not there')
@@ -38,24 +38,24 @@ Capybara::SpecHelper.spec '#has_select?' do
38
38
  ])
39
39
  end
40
40
 
41
- it "should be true after the given value is selected" do
41
+ it 'should be true after the given value is selected' do
42
42
  @session.select('Swedish', from: 'Locale')
43
43
  expect(@session).to have_select('Locale', selected: 'Swedish')
44
44
  end
45
45
 
46
- it "should be false after a different value is selected" do
46
+ it 'should be false after a different value is selected' do
47
47
  @session.select('Swedish', from: 'Locale')
48
48
  expect(@session).not_to have_select('Locale', selected: 'English')
49
49
  end
50
50
 
51
- it "should be true after the given values are selected" do
51
+ it 'should be true after the given values are selected' do
52
52
  @session.select('Boxers', from: 'Underwear')
53
53
  expect(@session).to have_select('Underwear', selected: [
54
54
  'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
55
55
  ])
56
56
  end
57
57
 
58
- it "should be false after one of the values is unselected" do
58
+ it 'should be false after one of the values is unselected' do
59
59
  @session.unselect('Briefs', from: 'Underwear')
60
60
  expect(@session).not_to have_select('Underwear', selected: [
61
61
  'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
@@ -69,20 +69,20 @@ Capybara::SpecHelper.spec '#has_select?' do
69
69
  end
70
70
 
71
71
  context 'with partial select' do
72
- it "should be true if a field with the given partial values is on the page" do
72
+ it 'should be true if a field with the given partial values is on the page' do
73
73
  expect(@session).to have_select('Underwear', with_selected: %w[Boxerbriefs Briefs])
74
74
  end
75
75
 
76
- it "should be false if a field with the given partial values is not on the page" do
76
+ it 'should be false if a field with the given partial values is not on the page' do
77
77
  expect(@session).not_to have_select('Underwear', with_selected: %w[Boxerbriefs Boxers])
78
78
  end
79
79
 
80
- it "should be true after the given partial value is selected" do
80
+ it 'should be true after the given partial value is selected' do
81
81
  @session.select('Boxers', from: 'Underwear')
82
82
  expect(@session).to have_select('Underwear', with_selected: %w[Boxerbriefs Boxers])
83
83
  end
84
84
 
85
- it "should be false after one of the given partial values is unselected" do
85
+ it 'should be false after one of the given partial values is unselected' do
86
86
  @session.unselect('Briefs', from: 'Underwear')
87
87
  expect(@session).not_to have_select('Underwear', with_selected: %w[Boxerbriefs Briefs])
88
88
  end
@@ -92,19 +92,19 @@ Capybara::SpecHelper.spec '#has_select?' do
92
92
  expect(@session).to have_select('Cake', with_selected: ['Chocolate Cake', 'Sponge Cake'])
93
93
  end
94
94
 
95
- it "should support non array partial values" do
95
+ it 'should support non array partial values' do
96
96
  expect(@session).to have_select('Underwear', with_selected: 'Briefs')
97
97
  expect(@session).not_to have_select('Underwear', with_selected: 'Boxers')
98
98
  end
99
99
  end
100
100
 
101
101
  context 'with exact options' do
102
- it "should be true if a field with the given options is on the page" do
102
+ it 'should be true if a field with the given options is on the page' do
103
103
  expect(@session).to have_select('Region', options: %w[Norway Sweden Finland])
104
104
  expect(@session).to have_select('Tendency', options: [])
105
105
  end
106
106
 
107
- it "should be false if the given field is not on the page" do
107
+ it 'should be false if the given field is not on the page' do
108
108
  expect(@session).not_to have_select('Locale', options: ['Swedish'])
109
109
  expect(@session).not_to have_select('Does not exist', options: ['John'])
110
110
  expect(@session).not_to have_select('City', options: ['London', 'Made up city'])
@@ -112,46 +112,46 @@ Capybara::SpecHelper.spec '#has_select?' do
112
112
  expect(@session).not_to have_select('Region', options: %w[Norway Norway Norway])
113
113
  end
114
114
 
115
- it "should be true even when the options are invisible, if the select itself is invisible" do
116
- expect(@session).to have_select("Icecream", visible: false, options: %w[Chocolate Vanilla Strawberry])
115
+ it 'should be true even when the options are invisible, if the select itself is invisible' do
116
+ expect(@session).to have_select('Icecream', visible: false, options: %w[Chocolate Vanilla Strawberry])
117
117
  end
118
118
  end
119
119
 
120
120
  context 'with partial options' do
121
- it "should be true if a field with the given partial options is on the page" do
121
+ it 'should be true if a field with the given partial options is on the page' do
122
122
  expect(@session).to have_select('Region', with_options: %w[Norway Sweden])
123
123
  expect(@session).to have_select('City', with_options: ['London'])
124
124
  end
125
125
 
126
- it "should be false if a field with the given partial options is not on the page" do
126
+ it 'should be false if a field with the given partial options is not on the page' do
127
127
  expect(@session).not_to have_select('Locale', with_options: ['Uruguayan'])
128
128
  expect(@session).not_to have_select('Does not exist', with_options: ['John'])
129
129
  expect(@session).not_to have_select('Region', with_options: %w[Norway Sweden Finland Latvia])
130
130
  end
131
131
 
132
- it "should be true even when the options are invisible, if the select itself is invisible" do
133
- expect(@session).to have_select("Icecream", visible: false, with_options: %w[Vanilla Strawberry])
132
+ it 'should be true even when the options are invisible, if the select itself is invisible' do
133
+ expect(@session).to have_select('Icecream', visible: false, with_options: %w[Vanilla Strawberry])
134
134
  end
135
135
  end
136
136
 
137
137
  context 'with multiple option' do
138
- it "should find multiple selects if true" do
138
+ it 'should find multiple selects if true' do
139
139
  expect(@session).to have_select('form_languages', multiple: true)
140
140
  expect(@session).not_to have_select('form_other_title', multiple: true)
141
141
  end
142
142
 
143
- it "should not find multiple selects if false" do
143
+ it 'should not find multiple selects if false' do
144
144
  expect(@session).not_to have_select('form_languages', multiple: false)
145
145
  expect(@session).to have_select('form_other_title', multiple: false)
146
146
  end
147
147
 
148
- it "should find both if not specified" do
148
+ it 'should find both if not specified' do
149
149
  expect(@session).to have_select('form_languages')
150
150
  expect(@session).to have_select('form_other_title')
151
151
  end
152
152
  end
153
153
 
154
- it "should support locator-less usage" do
154
+ it 'should support locator-less usage' do
155
155
  expect(@session.has_select?(with_options: %w[Norway Sweden])).to eq true
156
156
  expect(@session).to have_select(with_options: ['London'])
157
157
  expect(@session.has_select?(with_selected: %w[Commando Boxerbriefs])).to eq true
@@ -162,18 +162,18 @@ end
162
162
  Capybara::SpecHelper.spec '#has_no_select?' do
163
163
  before { @session.visit('/form') }
164
164
 
165
- it "should be false if the field is on the page" do
165
+ it 'should be false if the field is on the page' do
166
166
  expect(@session).not_to have_no_select('Locale')
167
167
  expect(@session).not_to have_no_select('form_region')
168
168
  expect(@session).not_to have_no_select('Languages')
169
169
  end
170
170
 
171
- it "should be true if the field is not on the page" do
171
+ it 'should be true if the field is not on the page' do
172
172
  expect(@session).to have_no_select('Monkey')
173
173
  end
174
174
 
175
175
  context 'with selected value' do
176
- it "should be false if a field with the given value is on the page" do
176
+ it 'should be false if a field with the given value is on the page' do
177
177
  expect(@session).not_to have_no_select('form_locale', selected: 'English')
178
178
  expect(@session).not_to have_no_select('Region', selected: 'Norway')
179
179
  expect(@session).not_to have_no_select('Underwear', selected: [
@@ -181,7 +181,7 @@ Capybara::SpecHelper.spec '#has_no_select?' do
181
181
  ])
182
182
  end
183
183
 
184
- it "should be true if the given field is not on the page" do
184
+ it 'should be true if the given field is not on the page' do
185
185
  expect(@session).to have_no_select('Locale', selected: 'Swedish')
186
186
  expect(@session).to have_no_select('Does not exist', selected: 'John')
187
187
  expect(@session).to have_no_select('City', selected: 'Not there')
@@ -196,24 +196,24 @@ Capybara::SpecHelper.spec '#has_no_select?' do
196
196
  ])
197
197
  end
198
198
 
199
- it "should be false after the given value is selected" do
199
+ it 'should be false after the given value is selected' do
200
200
  @session.select('Swedish', from: 'Locale')
201
201
  expect(@session).not_to have_no_select('Locale', selected: 'Swedish')
202
202
  end
203
203
 
204
- it "should be true after a different value is selected" do
204
+ it 'should be true after a different value is selected' do
205
205
  @session.select('Swedish', from: 'Locale')
206
206
  expect(@session).to have_no_select('Locale', selected: 'English')
207
207
  end
208
208
 
209
- it "should be false after the given values are selected" do
209
+ it 'should be false after the given values are selected' do
210
210
  @session.select('Boxers', from: 'Underwear')
211
211
  expect(@session).not_to have_no_select('Underwear', selected: [
212
212
  'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
213
213
  ])
214
214
  end
215
215
 
216
- it "should be true after one of the values is unselected" do
216
+ it 'should be true after one of the values is unselected' do
217
217
  @session.unselect('Briefs', from: 'Underwear')
218
218
  expect(@session).to have_no_select('Underwear', selected: [
219
219
  'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
@@ -222,36 +222,36 @@ Capybara::SpecHelper.spec '#has_no_select?' do
222
222
  end
223
223
 
224
224
  context 'with partial select' do
225
- it "should be false if a field with the given partial values is on the page" do
225
+ it 'should be false if a field with the given partial values is on the page' do
226
226
  expect(@session).not_to have_no_select('Underwear', with_selected: %w[Boxerbriefs Briefs])
227
227
  end
228
228
 
229
- it "should be true if a field with the given partial values is not on the page" do
229
+ it 'should be true if a field with the given partial values is not on the page' do
230
230
  expect(@session).to have_no_select('Underwear', with_selected: %w[Boxerbriefs Boxers])
231
231
  end
232
232
 
233
- it "should be false after the given partial value is selected" do
233
+ it 'should be false after the given partial value is selected' do
234
234
  @session.select('Boxers', from: 'Underwear')
235
235
  expect(@session).not_to have_no_select('Underwear', with_selected: %w[Boxerbriefs Boxers])
236
236
  end
237
237
 
238
- it "should be true after one of the given partial values is unselected" do
238
+ it 'should be true after one of the given partial values is unselected' do
239
239
  @session.unselect('Briefs', from: 'Underwear')
240
240
  expect(@session).to have_no_select('Underwear', with_selected: %w[Boxerbriefs Briefs])
241
241
  end
242
242
 
243
- it "should support non array partial values" do
243
+ it 'should support non array partial values' do
244
244
  expect(@session).not_to have_no_select('Underwear', with_selected: 'Briefs')
245
245
  expect(@session).to have_no_select('Underwear', with_selected: 'Boxers')
246
246
  end
247
247
  end
248
248
 
249
249
  context 'with exact options' do
250
- it "should be false if a field with the given options is on the page" do
250
+ it 'should be false if a field with the given options is on the page' do
251
251
  expect(@session).not_to have_no_select('Region', options: %w[Norway Sweden Finland])
252
252
  end
253
253
 
254
- it "should be true if the given field is not on the page" do
254
+ it 'should be true if the given field is not on the page' do
255
255
  expect(@session).to have_no_select('Locale', options: ['Swedish'])
256
256
  expect(@session).to have_no_select('Does not exist', options: ['John'])
257
257
  expect(@session).to have_no_select('City', options: ['London', 'Made up city'])
@@ -261,19 +261,19 @@ Capybara::SpecHelper.spec '#has_no_select?' do
261
261
  end
262
262
 
263
263
  context 'with partial options' do
264
- it "should be false if a field with the given partial options is on the page" do
264
+ it 'should be false if a field with the given partial options is on the page' do
265
265
  expect(@session).not_to have_no_select('Region', with_options: %w[Norway Sweden])
266
266
  expect(@session).not_to have_no_select('City', with_options: ['London'])
267
267
  end
268
268
 
269
- it "should be true if a field with the given partial options is not on the page" do
269
+ it 'should be true if a field with the given partial options is not on the page' do
270
270
  expect(@session).to have_no_select('Locale', with_options: ['Uruguayan'])
271
271
  expect(@session).to have_no_select('Does not exist', with_options: ['John'])
272
272
  expect(@session).to have_no_select('Region', with_options: %w[Norway Sweden Finland Latvia])
273
273
  end
274
274
  end
275
275
 
276
- it "should support locator-less usage" do
276
+ it 'should support locator-less usage' do
277
277
  expect(@session.has_no_select?(with_options: %w[Norway Sweden Finland Latvia])).to eq true
278
278
  expect(@session).to have_no_select(with_options: ['New London'])
279
279
  expect(@session.has_no_select?(with_selected: ['Boxers'])).to eq true
@@ -5,104 +5,104 @@ Capybara::SpecHelper.spec '#has_selector?' do
5
5
  @session.visit('/with_html')
6
6
  end
7
7
 
8
- it "should be true if the given selector is on the page" do
9
- expect(@session).to have_selector(:xpath, "//p")
10
- expect(@session).to have_selector(:css, "p a#foo")
8
+ it 'should be true if the given selector is on the page' do
9
+ expect(@session).to have_selector(:xpath, '//p')
10
+ expect(@session).to have_selector(:css, 'p a#foo')
11
11
  expect(@session).to have_selector("//p[contains(.,'est')]")
12
12
  end
13
13
 
14
- it "should be false if the given selector is not on the page" do
15
- expect(@session).not_to have_selector(:xpath, "//abbr")
16
- expect(@session).not_to have_selector(:css, "p a#doesnotexist")
14
+ it 'should be false if the given selector is not on the page' do
15
+ expect(@session).not_to have_selector(:xpath, '//abbr')
16
+ expect(@session).not_to have_selector(:css, 'p a#doesnotexist')
17
17
  expect(@session).not_to have_selector("//p[contains(.,'thisstringisnotonpage')]")
18
18
  end
19
19
 
20
- it "should use default selector" do
20
+ it 'should use default selector' do
21
21
  Capybara.default_selector = :css
22
- expect(@session).not_to have_selector("p a#doesnotexist")
23
- expect(@session).to have_selector("p a#foo")
22
+ expect(@session).not_to have_selector('p a#doesnotexist')
23
+ expect(@session).to have_selector('p a#foo')
24
24
  end
25
25
 
26
- it "should respect scopes" do
26
+ it 'should respect scopes' do
27
27
  @session.within "//p[@id='first']" do
28
28
  expect(@session).to have_selector(".//a[@id='foo']")
29
29
  expect(@session).not_to have_selector(".//a[@id='red']")
30
30
  end
31
31
  end
32
32
 
33
- it "should accept a filter block" do
34
- expect(@session).to have_selector(:css, "a", count: 1) { |el| el[:id] == "foo" }
33
+ it 'should accept a filter block' do
34
+ expect(@session).to have_selector(:css, 'a', count: 1) { |el| el[:id] == 'foo' }
35
35
  end
36
36
 
37
- context "with count" do
38
- it "should be true if the content is on the page the given number of times" do
39
- expect(@session).to have_selector("//p", count: 3)
37
+ context 'with count' do
38
+ it 'should be true if the content is on the page the given number of times' do
39
+ expect(@session).to have_selector('//p', count: 3)
40
40
  expect(@session).to have_selector("//p//a[@id='foo']", count: 1)
41
41
  expect(@session).to have_selector("//p[contains(.,'est')]", count: 1)
42
42
  end
43
43
 
44
- it "should be false if the content is on the page the given number of times" do
45
- expect(@session).not_to have_selector("//p", count: 6)
44
+ it 'should be false if the content is on the page the given number of times' do
45
+ expect(@session).not_to have_selector('//p', count: 6)
46
46
  expect(@session).not_to have_selector("//p//a[@id='foo']", count: 2)
47
47
  expect(@session).not_to have_selector("//p[contains(.,'est')]", count: 5)
48
48
  end
49
49
 
50
50
  it "should be false if the content isn't on the page at all" do
51
- expect(@session).not_to have_selector("//abbr", count: 2)
51
+ expect(@session).not_to have_selector('//abbr', count: 2)
52
52
  expect(@session).not_to have_selector("//p//a[@id='doesnotexist']", count: 1)
53
53
  end
54
54
  end
55
55
 
56
- context "with text" do
57
- it "should discard all matches where the given string is not contained" do
58
- expect(@session).to have_selector("//p//a", text: "Redirect", count: 1)
59
- expect(@session).not_to have_selector("//p", text: "Doesnotexist")
56
+ context 'with text' do
57
+ it 'should discard all matches where the given string is not contained' do
58
+ expect(@session).to have_selector('//p//a', text: 'Redirect', count: 1)
59
+ expect(@session).not_to have_selector('//p', text: 'Doesnotexist')
60
60
  end
61
61
 
62
- it "should respect visibility setting" do
63
- expect(@session).to have_selector(:id, "hidden-text", text: "Some of this text is hidden!", visible: false)
64
- expect(@session).not_to have_selector(:id, "hidden-text", text: "Some of this text is hidden!", visible: true)
62
+ it 'should respect visibility setting' do
63
+ expect(@session).to have_selector(:id, 'hidden-text', text: 'Some of this text is hidden!', visible: false)
64
+ expect(@session).not_to have_selector(:id, 'hidden-text', text: 'Some of this text is hidden!', visible: true)
65
65
  Capybara.ignore_hidden_elements = false
66
- expect(@session).to have_selector(:id, "hidden-text", text: "Some of this text is hidden!", visible: false)
66
+ expect(@session).to have_selector(:id, 'hidden-text', text: 'Some of this text is hidden!', visible: false)
67
67
  Capybara.visible_text_only = true
68
- expect(@session).not_to have_selector(:id, "hidden-text", text: "Some of this text is hidden!", visible: true)
68
+ expect(@session).not_to have_selector(:id, 'hidden-text', text: 'Some of this text is hidden!', visible: true)
69
69
  end
70
70
 
71
- it "should discard all matches where the given regexp is not matched" do
72
- expect(@session).to have_selector("//p//a", text: /re[dab]i/i, count: 1)
73
- expect(@session).not_to have_selector("//p//a", text: /Red$/)
71
+ it 'should discard all matches where the given regexp is not matched' do
72
+ expect(@session).to have_selector('//p//a', text: /re[dab]i/i, count: 1)
73
+ expect(@session).not_to have_selector('//p//a', text: /Red$/)
74
74
  end
75
75
 
76
- it "should raise when extra parameters passed" do
76
+ it 'should raise when extra parameters passed' do
77
77
  expect do
78
- expect(@session).to have_selector(:css, "p a#foo", 'extra')
78
+ expect(@session).to have_selector(:css, 'p a#foo', 'extra')
79
79
  end.to raise_error ArgumentError, /extra/
80
80
  end
81
81
  end
82
82
 
83
- context "with exact_text" do
84
- context "string" do
85
- it "should only match elements that match exactly" do
86
- expect(@session).to have_selector(:id, "h2one", exact_text: "Header Class Test One")
87
- expect(@session).to have_no_selector(:id, "h2one", exact_text: "Header Class Test")
83
+ context 'with exact_text' do
84
+ context 'string' do
85
+ it 'should only match elements that match exactly' do
86
+ expect(@session).to have_selector(:id, 'h2one', exact_text: 'Header Class Test One')
87
+ expect(@session).to have_no_selector(:id, 'h2one', exact_text: 'Header Class Test')
88
88
  end
89
89
  end
90
90
 
91
- context "boolean" do
92
- it "should only match elements that match exactly when true" do
93
- expect(@session).to have_selector(:id, "h2one", text: "Header Class Test One", exact_text: true)
94
- expect(@session).to have_no_selector(:id, "h2one", text: "Header Class Test", exact_text: true)
91
+ context 'boolean' do
92
+ it 'should only match elements that match exactly when true' do
93
+ expect(@session).to have_selector(:id, 'h2one', text: 'Header Class Test One', exact_text: true)
94
+ expect(@session).to have_no_selector(:id, 'h2one', text: 'Header Class Test', exact_text: true)
95
95
  end
96
96
 
97
- it "should match substrings when false" do
98
- expect(@session).to have_selector(:id, "h2one", text: "Header Class Test One", exact_text: false)
99
- expect(@session).to have_selector(:id, "h2one", text: "Header Class Test", exact_text: false)
97
+ it 'should match substrings when false' do
98
+ expect(@session).to have_selector(:id, 'h2one', text: 'Header Class Test One', exact_text: false)
99
+ expect(@session).to have_selector(:id, 'h2one', text: 'Header Class Test', exact_text: false)
100
100
  end
101
101
  end
102
102
  end
103
103
 
104
- context "datalist" do
105
- it "should match options" do
104
+ context 'datalist' do
105
+ it 'should match options' do
106
106
  @session.visit('/form')
107
107
  expect(@session).to have_selector(:datalist_input, with_options: %w[Jaguar Audi Mercedes])
108
108
  expect(@session).not_to have_selector(:datalist_input, with_options: %w[Ford Chevy])
@@ -115,63 +115,63 @@ Capybara::SpecHelper.spec '#has_no_selector?' do
115
115
  @session.visit('/with_html')
116
116
  end
117
117
 
118
- it "should be false if the given selector is on the page" do
119
- expect(@session).not_to have_no_selector(:xpath, "//p")
120
- expect(@session).not_to have_no_selector(:css, "p a#foo")
118
+ it 'should be false if the given selector is on the page' do
119
+ expect(@session).not_to have_no_selector(:xpath, '//p')
120
+ expect(@session).not_to have_no_selector(:css, 'p a#foo')
121
121
  expect(@session).not_to have_no_selector("//p[contains(.,'est')]")
122
122
  end
123
123
 
124
- it "should be true if the given selector is not on the page" do
125
- expect(@session).to have_no_selector(:xpath, "//abbr")
126
- expect(@session).to have_no_selector(:css, "p a#doesnotexist")
124
+ it 'should be true if the given selector is not on the page' do
125
+ expect(@session).to have_no_selector(:xpath, '//abbr')
126
+ expect(@session).to have_no_selector(:css, 'p a#doesnotexist')
127
127
  expect(@session).to have_no_selector("//p[contains(.,'thisstringisnotonpage')]")
128
128
  end
129
129
 
130
- it "should use default selector" do
130
+ it 'should use default selector' do
131
131
  Capybara.default_selector = :css
132
- expect(@session).to have_no_selector("p a#doesnotexist")
133
- expect(@session).not_to have_no_selector("p a#foo")
132
+ expect(@session).to have_no_selector('p a#doesnotexist')
133
+ expect(@session).not_to have_no_selector('p a#foo')
134
134
  end
135
135
 
136
- it "should respect scopes" do
136
+ it 'should respect scopes' do
137
137
  @session.within "//p[@id='first']" do
138
138
  expect(@session).not_to have_no_selector(".//a[@id='foo']")
139
139
  expect(@session).to have_no_selector(".//a[@id='red']")
140
140
  end
141
141
  end
142
142
 
143
- it "should accept a filter block" do
144
- expect(@session).to have_no_selector(:css, "a#foo") { |el| el[:id] != "foo" }
143
+ it 'should accept a filter block' do
144
+ expect(@session).to have_no_selector(:css, 'a#foo') { |el| el[:id] != 'foo' }
145
145
  end
146
146
 
147
- context "with count" do
148
- it "should be false if the content is on the page the given number of times" do
149
- expect(@session).not_to have_no_selector("//p", count: 3)
147
+ context 'with count' do
148
+ it 'should be false if the content is on the page the given number of times' do
149
+ expect(@session).not_to have_no_selector('//p', count: 3)
150
150
  expect(@session).not_to have_no_selector("//p//a[@id='foo']", count: 1)
151
151
  expect(@session).not_to have_no_selector("//p[contains(.,'est')]", count: 1)
152
152
  end
153
153
 
154
- it "should be true if the content is on the page the wrong number of times" do
155
- expect(@session).to have_no_selector("//p", count: 6)
154
+ it 'should be true if the content is on the page the wrong number of times' do
155
+ expect(@session).to have_no_selector('//p', count: 6)
156
156
  expect(@session).to have_no_selector("//p//a[@id='foo']", count: 2)
157
157
  expect(@session).to have_no_selector("//p[contains(.,'est')]", count: 5)
158
158
  end
159
159
 
160
160
  it "should be true if the content isn't on the page at all" do
161
- expect(@session).to have_no_selector("//abbr", count: 2)
161
+ expect(@session).to have_no_selector('//abbr', count: 2)
162
162
  expect(@session).to have_no_selector("//p//a[@id='doesnotexist']", count: 1)
163
163
  end
164
164
  end
165
165
 
166
- context "with text" do
167
- it "should discard all matches where the given string is contained" do
168
- expect(@session).not_to have_no_selector("//p//a", text: "Redirect", count: 1)
169
- expect(@session).to have_no_selector("//p", text: "Doesnotexist")
166
+ context 'with text' do
167
+ it 'should discard all matches where the given string is contained' do
168
+ expect(@session).not_to have_no_selector('//p//a', text: 'Redirect', count: 1)
169
+ expect(@session).to have_no_selector('//p', text: 'Doesnotexist')
170
170
  end
171
171
 
172
- it "should discard all matches where the given regexp is matched" do
173
- expect(@session).not_to have_no_selector("//p//a", text: /re[dab]i/i, count: 1)
174
- expect(@session).to have_no_selector("//p//a", text: /Red$/)
172
+ it 'should discard all matches where the given regexp is matched' do
173
+ expect(@session).not_to have_no_selector('//p//a', text: /re[dab]i/i, count: 1)
174
+ expect(@session).to have_no_selector('//p//a', text: /Red$/)
175
175
  end
176
176
  end
177
177
  end