capybara 3.13.2 → 3.40.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 (260) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/History.md +587 -16
  4. data/README.md +240 -90
  5. data/lib/capybara/config.rb +24 -11
  6. data/lib/capybara/cucumber.rb +1 -1
  7. data/lib/capybara/driver/base.rb +8 -0
  8. data/lib/capybara/driver/node.rb +20 -4
  9. data/lib/capybara/dsl.rb +5 -3
  10. data/lib/capybara/helpers.rb +25 -4
  11. data/lib/capybara/minitest/spec.rb +174 -90
  12. data/lib/capybara/minitest.rb +256 -142
  13. data/lib/capybara/node/actions.rb +123 -77
  14. data/lib/capybara/node/base.rb +20 -12
  15. data/lib/capybara/node/document.rb +2 -2
  16. data/lib/capybara/node/document_matchers.rb +3 -3
  17. data/lib/capybara/node/element.rb +223 -117
  18. data/lib/capybara/node/finders.rb +81 -71
  19. data/lib/capybara/node/matchers.rb +271 -134
  20. data/lib/capybara/node/simple.rb +18 -5
  21. data/lib/capybara/node/whitespace_normalizer.rb +81 -0
  22. data/lib/capybara/queries/active_element_query.rb +18 -0
  23. data/lib/capybara/queries/ancestor_query.rb +8 -9
  24. data/lib/capybara/queries/base_query.rb +3 -2
  25. data/lib/capybara/queries/current_path_query.rb +15 -5
  26. data/lib/capybara/queries/selector_query.rb +364 -54
  27. data/lib/capybara/queries/sibling_query.rb +8 -6
  28. data/lib/capybara/queries/style_query.rb +2 -2
  29. data/lib/capybara/queries/text_query.rb +13 -1
  30. data/lib/capybara/queries/title_query.rb +1 -1
  31. data/lib/capybara/rack_test/browser.rb +76 -11
  32. data/lib/capybara/rack_test/driver.rb +10 -5
  33. data/lib/capybara/rack_test/errors.rb +6 -0
  34. data/lib/capybara/rack_test/form.rb +31 -9
  35. data/lib/capybara/rack_test/node.rb +74 -23
  36. data/lib/capybara/registration_container.rb +41 -0
  37. data/lib/capybara/registrations/drivers.rb +42 -0
  38. data/lib/capybara/registrations/patches/puma_ssl.rb +29 -0
  39. data/lib/capybara/registrations/servers.rb +66 -0
  40. data/lib/capybara/result.rb +44 -20
  41. data/lib/capybara/rspec/matcher_proxies.rb +13 -11
  42. data/lib/capybara/rspec/matchers/base.rb +31 -16
  43. data/lib/capybara/rspec/matchers/compound.rb +1 -1
  44. data/lib/capybara/rspec/matchers/count_sugar.rb +37 -0
  45. data/lib/capybara/rspec/matchers/have_ancestor.rb +28 -0
  46. data/lib/capybara/rspec/matchers/have_current_path.rb +2 -2
  47. data/lib/capybara/rspec/matchers/have_selector.rb +21 -21
  48. data/lib/capybara/rspec/matchers/have_sibling.rb +27 -0
  49. data/lib/capybara/rspec/matchers/have_text.rb +4 -4
  50. data/lib/capybara/rspec/matchers/have_title.rb +2 -2
  51. data/lib/capybara/rspec/matchers/match_selector.rb +3 -3
  52. data/lib/capybara/rspec/matchers/match_style.rb +7 -2
  53. data/lib/capybara/rspec/matchers/spatial_sugar.rb +39 -0
  54. data/lib/capybara/rspec/matchers.rb +111 -68
  55. data/lib/capybara/rspec.rb +2 -0
  56. data/lib/capybara/selector/builders/css_builder.rb +11 -7
  57. data/lib/capybara/selector/builders/xpath_builder.rb +5 -3
  58. data/lib/capybara/selector/css.rb +11 -9
  59. data/lib/capybara/selector/definition/button.rb +68 -0
  60. data/lib/capybara/selector/definition/checkbox.rb +26 -0
  61. data/lib/capybara/selector/definition/css.rb +10 -0
  62. data/lib/capybara/selector/definition/datalist_input.rb +35 -0
  63. data/lib/capybara/selector/definition/datalist_option.rb +25 -0
  64. data/lib/capybara/selector/definition/element.rb +28 -0
  65. data/lib/capybara/selector/definition/field.rb +40 -0
  66. data/lib/capybara/selector/definition/fieldset.rb +14 -0
  67. data/lib/capybara/selector/definition/file_field.rb +13 -0
  68. data/lib/capybara/selector/definition/fillable_field.rb +33 -0
  69. data/lib/capybara/selector/definition/frame.rb +17 -0
  70. data/lib/capybara/selector/definition/id.rb +6 -0
  71. data/lib/capybara/selector/definition/label.rb +62 -0
  72. data/lib/capybara/selector/definition/link.rb +55 -0
  73. data/lib/capybara/selector/definition/link_or_button.rb +16 -0
  74. data/lib/capybara/selector/definition/option.rb +27 -0
  75. data/lib/capybara/selector/definition/radio_button.rb +27 -0
  76. data/lib/capybara/selector/definition/select.rb +81 -0
  77. data/lib/capybara/selector/definition/table.rb +109 -0
  78. data/lib/capybara/selector/definition/table_row.rb +21 -0
  79. data/lib/capybara/selector/definition/xpath.rb +5 -0
  80. data/lib/capybara/selector/definition.rb +280 -0
  81. data/lib/capybara/selector/filter_set.rb +19 -18
  82. data/lib/capybara/selector/filters/base.rb +11 -2
  83. data/lib/capybara/selector/filters/locator_filter.rb +13 -3
  84. data/lib/capybara/selector/regexp_disassembler.rb +11 -7
  85. data/lib/capybara/selector/selector.rb +50 -440
  86. data/lib/capybara/selector/xpath_extensions.rb +17 -0
  87. data/lib/capybara/selector.rb +473 -482
  88. data/lib/capybara/selenium/atoms/getAttribute.min.js +1 -0
  89. data/lib/capybara/selenium/atoms/isDisplayed.min.js +1 -0
  90. data/lib/capybara/selenium/atoms/src/getAttribute.js +161 -0
  91. data/lib/capybara/selenium/atoms/src/isDisplayed.js +454 -0
  92. data/lib/capybara/selenium/driver.rb +174 -62
  93. data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +74 -18
  94. data/lib/capybara/selenium/driver_specializations/edge_driver.rb +128 -0
  95. data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +37 -3
  96. data/lib/capybara/selenium/driver_specializations/internet_explorer_driver.rb +14 -1
  97. data/lib/capybara/selenium/driver_specializations/safari_driver.rb +24 -0
  98. data/lib/capybara/selenium/extensions/file_input_click_emulation.rb +34 -0
  99. data/lib/capybara/selenium/extensions/find.rb +68 -45
  100. data/lib/capybara/selenium/extensions/html5_drag.rb +192 -22
  101. data/lib/capybara/selenium/extensions/modifier_keys_stack.rb +28 -0
  102. data/lib/capybara/selenium/extensions/scroll.rb +8 -10
  103. data/lib/capybara/selenium/node.rb +268 -72
  104. data/lib/capybara/selenium/nodes/chrome_node.rb +105 -9
  105. data/lib/capybara/selenium/nodes/edge_node.rb +110 -0
  106. data/lib/capybara/selenium/nodes/firefox_node.rb +51 -61
  107. data/lib/capybara/selenium/nodes/ie_node.rb +22 -0
  108. data/lib/capybara/selenium/nodes/safari_node.rb +118 -0
  109. data/lib/capybara/selenium/patches/atoms.rb +18 -0
  110. data/lib/capybara/selenium/patches/is_displayed.rb +16 -0
  111. data/lib/capybara/selenium/patches/logs.rb +45 -0
  112. data/lib/capybara/selenium/patches/pause_duration_fix.rb +1 -1
  113. data/lib/capybara/selenium/patches/persistent_client.rb +20 -0
  114. data/lib/capybara/server/animation_disabler.rb +43 -21
  115. data/lib/capybara/server/checker.rb +6 -2
  116. data/lib/capybara/server/middleware.rb +25 -13
  117. data/lib/capybara/server.rb +20 -4
  118. data/lib/capybara/session/config.rb +15 -11
  119. data/lib/capybara/session/matchers.rb +11 -11
  120. data/lib/capybara/session.rb +162 -131
  121. data/lib/capybara/spec/public/offset.js +6 -0
  122. data/lib/capybara/spec/public/test.js +105 -6
  123. data/lib/capybara/spec/session/accept_alert_spec.rb +1 -1
  124. data/lib/capybara/spec/session/active_element_spec.rb +31 -0
  125. data/lib/capybara/spec/session/all_spec.rb +89 -15
  126. data/lib/capybara/spec/session/ancestor_spec.rb +5 -0
  127. data/lib/capybara/spec/session/assert_current_path_spec.rb +5 -2
  128. data/lib/capybara/spec/session/assert_text_spec.rb +26 -22
  129. data/lib/capybara/spec/session/attach_file_spec.rb +64 -31
  130. data/lib/capybara/spec/session/check_spec.rb +26 -4
  131. data/lib/capybara/spec/session/choose_spec.rb +14 -2
  132. data/lib/capybara/spec/session/click_button_spec.rb +109 -61
  133. data/lib/capybara/spec/session/click_link_or_button_spec.rb +9 -0
  134. data/lib/capybara/spec/session/click_link_spec.rb +23 -1
  135. data/lib/capybara/spec/session/current_scope_spec.rb +1 -1
  136. data/lib/capybara/spec/session/current_url_spec.rb +11 -1
  137. data/lib/capybara/spec/session/element/matches_selector_spec.rb +40 -39
  138. data/lib/capybara/spec/session/evaluate_script_spec.rb +12 -0
  139. data/lib/capybara/spec/session/fill_in_spec.rb +46 -5
  140. data/lib/capybara/spec/session/find_link_spec.rb +10 -0
  141. data/lib/capybara/spec/session/find_spec.rb +80 -7
  142. data/lib/capybara/spec/session/first_spec.rb +2 -2
  143. data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +14 -1
  144. data/lib/capybara/spec/session/frame/within_frame_spec.rb +14 -1
  145. data/lib/capybara/spec/session/has_all_selectors_spec.rb +5 -5
  146. data/lib/capybara/spec/session/has_ancestor_spec.rb +46 -0
  147. data/lib/capybara/spec/session/has_any_selectors_spec.rb +6 -2
  148. data/lib/capybara/spec/session/has_button_spec.rb +81 -0
  149. data/lib/capybara/spec/session/has_css_spec.rb +45 -8
  150. data/lib/capybara/spec/session/has_current_path_spec.rb +22 -7
  151. data/lib/capybara/spec/session/has_element_spec.rb +47 -0
  152. data/lib/capybara/spec/session/has_field_spec.rb +59 -1
  153. data/lib/capybara/spec/session/has_link_spec.rb +40 -0
  154. data/lib/capybara/spec/session/has_none_selectors_spec.rb +7 -7
  155. data/lib/capybara/spec/session/has_select_spec.rb +42 -8
  156. data/lib/capybara/spec/session/has_selector_spec.rb +19 -4
  157. data/lib/capybara/spec/session/has_sibling_spec.rb +50 -0
  158. data/lib/capybara/spec/session/has_table_spec.rb +177 -0
  159. data/lib/capybara/spec/session/has_text_spec.rb +31 -3
  160. data/lib/capybara/spec/session/html_spec.rb +1 -1
  161. data/lib/capybara/spec/session/matches_style_spec.rb +6 -4
  162. data/lib/capybara/spec/session/node_spec.rb +697 -23
  163. data/lib/capybara/spec/session/node_wrapper_spec.rb +1 -1
  164. data/lib/capybara/spec/session/refresh_spec.rb +2 -1
  165. data/lib/capybara/spec/session/reset_session_spec.rb +21 -7
  166. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +2 -2
  167. data/lib/capybara/spec/session/save_page_spec.rb +4 -4
  168. data/lib/capybara/spec/session/save_screenshot_spec.rb +4 -4
  169. data/lib/capybara/spec/session/scroll_spec.rb +9 -7
  170. data/lib/capybara/spec/session/select_spec.rb +5 -10
  171. data/lib/capybara/spec/session/selectors_spec.rb +24 -3
  172. data/lib/capybara/spec/session/uncheck_spec.rb +3 -3
  173. data/lib/capybara/spec/session/unselect_spec.rb +1 -1
  174. data/lib/capybara/spec/session/visit_spec.rb +20 -0
  175. data/lib/capybara/spec/session/window/become_closed_spec.rb +20 -17
  176. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +1 -1
  177. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +1 -1
  178. data/lib/capybara/spec/session/window/window_spec.rb +54 -57
  179. data/lib/capybara/spec/session/window/windows_spec.rb +2 -2
  180. data/lib/capybara/spec/session/within_spec.rb +36 -0
  181. data/lib/capybara/spec/spec_helper.rb +30 -19
  182. data/lib/capybara/spec/test_app.rb +122 -34
  183. data/lib/capybara/spec/views/animated.erb +49 -0
  184. data/lib/capybara/spec/views/form.erb +86 -8
  185. data/lib/capybara/spec/views/frame_child.erb +3 -2
  186. data/lib/capybara/spec/views/frame_one.erb +2 -1
  187. data/lib/capybara/spec/views/frame_parent.erb +1 -1
  188. data/lib/capybara/spec/views/frame_two.erb +1 -1
  189. data/lib/capybara/spec/views/initial_alert.erb +2 -1
  190. data/lib/capybara/spec/views/layout.erb +10 -0
  191. data/lib/capybara/spec/views/obscured.erb +10 -10
  192. data/lib/capybara/spec/views/offset.erb +33 -0
  193. data/lib/capybara/spec/views/path.erb +2 -2
  194. data/lib/capybara/spec/views/popup_one.erb +1 -1
  195. data/lib/capybara/spec/views/popup_two.erb +1 -1
  196. data/lib/capybara/spec/views/react.erb +45 -0
  197. data/lib/capybara/spec/views/scroll.erb +2 -1
  198. data/lib/capybara/spec/views/spatial.erb +31 -0
  199. data/lib/capybara/spec/views/tables.erb +67 -0
  200. data/lib/capybara/spec/views/with_animation.erb +39 -4
  201. data/lib/capybara/spec/views/with_base_tag.erb +2 -2
  202. data/lib/capybara/spec/views/with_dragula.erb +24 -0
  203. data/lib/capybara/spec/views/with_fixed_header_footer.erb +2 -1
  204. data/lib/capybara/spec/views/with_hover.erb +3 -2
  205. data/lib/capybara/spec/views/with_hover1.erb +10 -0
  206. data/lib/capybara/spec/views/with_html.erb +34 -6
  207. data/lib/capybara/spec/views/with_jquery_animation.erb +24 -0
  208. data/lib/capybara/spec/views/with_js.erb +7 -4
  209. data/lib/capybara/spec/views/with_jstree.erb +26 -0
  210. data/lib/capybara/spec/views/with_namespace.erb +1 -0
  211. data/lib/capybara/spec/views/with_scope.erb +2 -2
  212. data/lib/capybara/spec/views/with_scope_other.erb +6 -0
  213. data/lib/capybara/spec/views/with_shadow.erb +31 -0
  214. data/lib/capybara/spec/views/with_slow_unload.erb +2 -1
  215. data/lib/capybara/spec/views/with_sortable_js.erb +21 -0
  216. data/lib/capybara/spec/views/with_unload_alert.erb +1 -0
  217. data/lib/capybara/spec/views/with_windows.erb +1 -1
  218. data/lib/capybara/spec/views/within_frames.erb +1 -1
  219. data/lib/capybara/version.rb +1 -1
  220. data/lib/capybara/window.rb +14 -18
  221. data/lib/capybara.rb +91 -126
  222. data/spec/basic_node_spec.rb +30 -16
  223. data/spec/capybara_spec.rb +40 -28
  224. data/spec/counter_spec.rb +35 -0
  225. data/spec/css_builder_spec.rb +3 -1
  226. data/spec/css_splitter_spec.rb +1 -1
  227. data/spec/dsl_spec.rb +33 -22
  228. data/spec/filter_set_spec.rb +5 -5
  229. data/spec/fixtures/selenium_driver_rspec_failure.rb +3 -3
  230. data/spec/fixtures/selenium_driver_rspec_success.rb +3 -3
  231. data/spec/minitest_spec.rb +24 -2
  232. data/spec/minitest_spec_spec.rb +60 -45
  233. data/spec/per_session_config_spec.rb +1 -1
  234. data/spec/rack_test_spec.rb +131 -98
  235. data/spec/regexp_dissassembler_spec.rb +53 -39
  236. data/spec/result_spec.rb +68 -66
  237. data/spec/rspec/features_spec.rb +9 -4
  238. data/spec/rspec/scenarios_spec.rb +6 -2
  239. data/spec/rspec/shared_spec_matchers.rb +137 -98
  240. data/spec/rspec_matchers_spec.rb +25 -0
  241. data/spec/rspec_spec.rb +23 -21
  242. data/spec/sauce_spec_chrome.rb +43 -0
  243. data/spec/selector_spec.rb +77 -21
  244. data/spec/selenium_spec_chrome.rb +141 -39
  245. data/spec/selenium_spec_chrome_remote.rb +32 -17
  246. data/spec/selenium_spec_edge.rb +36 -8
  247. data/spec/selenium_spec_firefox.rb +110 -68
  248. data/spec/selenium_spec_firefox_remote.rb +22 -15
  249. data/spec/selenium_spec_ie.rb +29 -22
  250. data/spec/selenium_spec_safari.rb +162 -0
  251. data/spec/server_spec.rb +153 -81
  252. data/spec/session_spec.rb +11 -4
  253. data/spec/shared_selenium_node.rb +79 -0
  254. data/spec/shared_selenium_session.rb +179 -74
  255. data/spec/spec_helper.rb +80 -5
  256. data/spec/whitespace_normalizer_spec.rb +54 -0
  257. data/spec/xpath_builder_spec.rb +3 -1
  258. metadata +218 -30
  259. data/lib/capybara/spec/session/source_spec.rb +0 -0
  260. data/lib/capybara/spec/views/with_title.erb +0 -5
@@ -12,7 +12,7 @@ Capybara::SpecHelper.spec '#have_all_of_selectors' do
12
12
  it 'should be false if any of the given selectors are not on the page' do
13
13
  expect do
14
14
  expect(@session).to have_all_of_selectors(:css, 'p a#foo', 'h2#h2three', 'h2#h2one')
15
- end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
15
+ end.to raise_error RSpec::Expectations::ExpectationNotMetError
16
16
  end
17
17
 
18
18
  it 'should use default selector' do
@@ -20,7 +20,7 @@ Capybara::SpecHelper.spec '#have_all_of_selectors' do
20
20
  expect(@session).to have_all_of_selectors('p a#foo', 'h2#h2two', 'h2#h2one')
21
21
  expect do
22
22
  expect(@session).to have_all_of_selectors('p a#foo', 'h2#h2three', 'h2#h2one')
23
- end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
23
+ end.to raise_error RSpec::Expectations::ExpectationNotMetError
24
24
  end
25
25
 
26
26
  context 'should respect scopes' do
@@ -29,7 +29,7 @@ Capybara::SpecHelper.spec '#have_all_of_selectors' do
29
29
  expect(@session).to have_all_of_selectors(".//a[@id='foo']")
30
30
  expect do
31
31
  expect(@session).to have_all_of_selectors(".//a[@id='red']")
32
- end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
32
+ end.to raise_error RSpec::Expectations::ExpectationNotMetError
33
33
  end
34
34
  end
35
35
 
@@ -38,7 +38,7 @@ Capybara::SpecHelper.spec '#have_all_of_selectors' do
38
38
  expect(el).to have_all_of_selectors(".//a[@id='foo']")
39
39
  expect do
40
40
  expect(el).to have_all_of_selectors(".//a[@id='red']")
41
- end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
41
+ end.to raise_error RSpec::Expectations::ExpectationNotMetError
42
42
  end
43
43
  end
44
44
 
@@ -47,7 +47,7 @@ Capybara::SpecHelper.spec '#have_all_of_selectors' do
47
47
  expect(@session).to have_all_of_selectors(:field, 'normal', 'additional_newline', type: :textarea)
48
48
  expect do
49
49
  expect(@session).to have_all_of_selectors(:field, 'normal', 'test_field', 'additional_newline', type: :textarea)
50
- end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
50
+ end.to raise_error RSpec::Expectations::ExpectationNotMetError
51
51
  end
52
52
  end
53
53
 
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ Capybara::SpecHelper.spec '#have_ancestor' do
4
+ before do
5
+ @session.visit('/with_html')
6
+ end
7
+
8
+ it 'should assert an ancestor using the given locator' do
9
+ el = @session.find(:css, '#ancestor1')
10
+ expect(el).to have_ancestor(:css, '#ancestor2')
11
+ end
12
+
13
+ it 'should assert an ancestor even if not parent' do
14
+ el = @session.find(:css, '#child')
15
+ expect(el).to have_ancestor(:css, '#ancestor3')
16
+ end
17
+
18
+ it 'should not raise an error if there are multiple matches' do
19
+ el = @session.find(:css, '#child')
20
+ expect(el).to have_ancestor(:css, 'div')
21
+ end
22
+
23
+ it 'should allow counts to be specified' do
24
+ el = @session.find(:css, '#child')
25
+
26
+ expect do
27
+ expect(el).to have_ancestor(:css, 'div').once
28
+ end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
29
+
30
+ expect(el).to have_ancestor(:css, 'div').exactly(3).times
31
+ end
32
+ end
33
+
34
+ Capybara::SpecHelper.spec '#have_no_ancestor' do
35
+ before do
36
+ @session.visit('/with_html')
37
+ end
38
+
39
+ it 'should assert no matching ancestor' do
40
+ el = @session.find(:css, '#ancestor1')
41
+ expect(el).to have_no_ancestor(:css, '#child')
42
+ expect(el).to have_no_ancestor(:css, '#ancestor1_sibling')
43
+ expect(el).not_to have_ancestor(:css, '#child')
44
+ expect(el).not_to have_ancestor(:css, '#ancestor1_sibling')
45
+ end
46
+ end
@@ -12,7 +12,7 @@ Capybara::SpecHelper.spec '#have_any_of_selectors' do
12
12
  it 'should be false if none of the given selectors are not on the page' do
13
13
  expect do
14
14
  expect(@session).to have_any_of_selectors(:css, 'span a#foo', 'h2#h2nope', 'h2#h2one_no')
15
- end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
15
+ end.to raise_error RSpec::Expectations::ExpectationNotMetError
16
16
  end
17
17
 
18
18
  it 'should use default selector' do
@@ -20,6 +20,10 @@ Capybara::SpecHelper.spec '#have_any_of_selectors' do
20
20
  expect(@session).to have_any_of_selectors('p a#foo', 'h2#h2two', 'a#not_on_page')
21
21
  expect do
22
22
  expect(@session).to have_any_of_selectors('p a#blah', 'h2#h2three')
23
- end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
23
+ end.to raise_error RSpec::Expectations::ExpectationNotMetError
24
+ end
25
+
26
+ it 'should be negateable' do
27
+ expect(@session).not_to have_any_of_selectors(:css, 'span a#foo', 'h2#h2nope', 'h2#h2one_no')
24
28
  end
25
29
  end
@@ -9,6 +9,8 @@ Capybara::SpecHelper.spec '#has_button?' do
9
9
  expect(@session).to have_button('med')
10
10
  expect(@session).to have_button('crap321')
11
11
  expect(@session).to have_button(:crap321)
12
+ expect(@session).to have_button('button with label element')
13
+ expect(@session).to have_button('button within label element')
12
14
  end
13
15
 
14
16
  it 'should be true for disabled buttons if disabled: true' do
@@ -39,6 +41,48 @@ Capybara::SpecHelper.spec '#has_button?' do
39
41
  expect(@session).to have_button('awe123', type: 'submit')
40
42
  expect(@session).not_to have_button('awe123', type: 'reset')
41
43
  end
44
+
45
+ it 'should be true for role=button when enable_aria_role: true' do
46
+ expect(@session).to have_button('ARIA button', enable_aria_role: true)
47
+ end
48
+
49
+ it 'should be false for a role=button within a label when enable_aria_role: true' do
50
+ expect(@session).not_to have_button('role=button within label', enable_aria_role: true)
51
+ end
52
+
53
+ it 'should be false for role=button when enable_aria_role: false' do
54
+ expect(@session).not_to have_button('ARIA button', enable_aria_role: false)
55
+ end
56
+
57
+ it 'should be false for a role=button within a label when enable_aria_role: false' do
58
+ expect(@session).not_to have_button('role=button within label', enable_aria_role: false)
59
+ end
60
+
61
+ it 'should not affect other selectors when enable_aria_role: true' do
62
+ expect(@session).to have_button('Click me!', enable_aria_role: true)
63
+ end
64
+
65
+ it 'should not affect other selectors when enable_aria_role: false' do
66
+ expect(@session).to have_button('Click me!', enable_aria_role: false)
67
+ end
68
+
69
+ context 'with focused:', requires: [:active_element] do
70
+ it 'should be true if a field has focus when focused: true' do
71
+ @session.send_keys(:tab)
72
+
73
+ expect(@session).to have_button('A Button', focused: true)
74
+ end
75
+
76
+ it 'should be true if a field does not have focus when focused: false' do
77
+ expect(@session).to have_button('A Button', focused: false)
78
+ end
79
+ end
80
+
81
+ it 'should raise an error if an invalid option is passed' do
82
+ expect do
83
+ expect(@session).to have_button('A Button', invalid: true)
84
+ end.to raise_error(ArgumentError, 'Invalid option(s) :invalid, should be one of :above, :below, :left_of, :right_of, :near, :count, :minimum, :maximum, :between, :text, :id, :class, :style, :visible, :obscured, :exact, :exact_text, :normalize_ws, :match, :wait, :filter_set, :focused, :disabled, :name, :value, :title, :type')
85
+ end
42
86
  end
43
87
 
44
88
  Capybara::SpecHelper.spec '#has_no_button?' do
@@ -66,4 +110,41 @@ Capybara::SpecHelper.spec '#has_no_button?' do
66
110
  it 'should be false for disabled buttons if disabled: false' do
67
111
  expect(@session).to have_no_button('Disabled button', disabled: false)
68
112
  end
113
+
114
+ it 'should be true for role=button when enable_aria_role: false' do
115
+ expect(@session).to have_no_button('ARIA button', enable_aria_role: false)
116
+ end
117
+
118
+ it 'should be true for role=button within a label when enable_aria_role: false' do
119
+ expect(@session).to have_no_button('role=button within label', enable_aria_role: false)
120
+ end
121
+
122
+ it 'should be false for role=button when enable_aria_role: true' do
123
+ expect(@session).not_to have_no_button('ARIA button', enable_aria_role: true)
124
+ end
125
+
126
+ it 'should be true for a role=button within a label when enable_aria_role: true' do
127
+ # label element does not associate with aria button
128
+ expect(@session).to have_no_button('role=button within label', enable_aria_role: true)
129
+ end
130
+
131
+ it 'should not affect other selectors when enable_aria_role: true' do
132
+ expect(@session).to have_no_button('Junk button that does not exist', enable_aria_role: true)
133
+ end
134
+
135
+ it 'should not affect other selectors when enable_aria_role: false' do
136
+ expect(@session).to have_no_button('Junk button that does not exist', enable_aria_role: false)
137
+ end
138
+
139
+ context 'with focused:', requires: [:active_element] do
140
+ it 'should be true if a button does not have focus when focused: true' do
141
+ expect(@session).to have_no_button('A Button', focused: true)
142
+ end
143
+
144
+ it 'should be false if a button has focus when focused: false' do
145
+ @session.send_keys(:tab)
146
+
147
+ expect(@session).to have_no_button('A Button', focused: false)
148
+ end
149
+ end
69
150
  end
@@ -10,11 +10,13 @@ Capybara::SpecHelper.spec '#has_css?' do
10
10
  expect(@session).to have_css('p a#foo')
11
11
  end
12
12
 
13
- it 'should take a symbol as the selector' do
13
+ it 'should warn when passed a symbol' do
14
14
  # This was never a specifically accepted format but it has worked for a
15
- # lot of versions. Probably should keep it until at least 4.0
16
- # TODO: consider not supporting symbol for the CSS selector.
15
+ # lot of versions.
16
+ # TODO: Remove in 4.0
17
+ allow(Capybara::Helpers).to receive(:warn).and_return(nil)
17
18
  expect(@session).to have_css(:p)
19
+ expect(Capybara::Helpers).to have_received(:warn)
18
20
  end
19
21
 
20
22
  it 'should be false if the given selector is not on the page' do
@@ -113,13 +115,20 @@ Capybara::SpecHelper.spec '#has_css?' do
113
115
  end
114
116
 
115
117
  context 'with predicates_wait == false' do
116
- it 'should not wait for content to appear', requires: [:js] do
118
+ before do
117
119
  Capybara.predicates_wait = false
118
- Capybara.default_max_wait_time = 2
120
+ Capybara.default_max_wait_time = 5
119
121
  @session.visit('/with_js')
120
122
  @session.click_link('Click me')
123
+ end
124
+
125
+ it 'should not wait for content to appear', requires: [:js] do
121
126
  expect(@session.has_css?("input[type='submit'][value='New Here']")).to be false
122
127
  end
128
+
129
+ it 'should should the default wait time if true is passed for :wait', requires: [:js] do
130
+ expect(@session.has_css?("input[type='submit'][value='New Here']", wait: true)).to be true
131
+ end
123
132
  end
124
133
 
125
134
  context 'with between' do
@@ -139,7 +148,9 @@ Capybara::SpecHelper.spec '#has_css?' do
139
148
  context 'with count' do
140
149
  it 'should be true if the content occurs the given number of times' do
141
150
  expect(@session).to have_css('p', count: 3)
151
+ expect(@session).to have_css('p').exactly(3).times
142
152
  expect(@session).to have_css('p a#foo', count: 1)
153
+ expect(@session).to have_css('p a#foo').once
143
154
  expect(@session).to have_css('p a.doesnotexist', count: 0)
144
155
  expect(@session).to have_css('li', class: /guitar|drummer/, count: 4)
145
156
  expect(@session).to have_css('li', id: /john|paul/, class: /guitar|drummer/, count: 2)
@@ -154,6 +165,7 @@ Capybara::SpecHelper.spec '#has_css?' do
154
165
 
155
166
  it 'should be false if the content occurs a different number of times than the given' do
156
167
  expect(@session).not_to have_css('p', count: 6)
168
+ expect(@session).not_to have_css('p').exactly(5).times
157
169
  expect(@session).not_to have_css('p a#foo', count: 2)
158
170
  expect(@session).not_to have_css('p a.doesnotexist', count: 1)
159
171
  end
@@ -168,14 +180,16 @@ Capybara::SpecHelper.spec '#has_css?' do
168
180
  it 'should be true when content occurs same or fewer times than given' do
169
181
  expect(@session).to have_css('h2.head', maximum: 5) # edge case
170
182
  expect(@session).to have_css('h2', maximum: 10)
183
+ expect(@session).to have_css('h2').at_most(10).times
171
184
  expect(@session).to have_css('p a.doesnotexist', maximum: 1)
172
185
  expect(@session).to have_css('p a.doesnotexist', maximum: 0)
173
186
  end
174
187
 
175
188
  it 'should be false when content occurs more times than given' do
176
- expect(@session).not_to have_css('h2.head', maximum: 4) # edge case
177
- expect(@session).not_to have_css('h2', maximum: 3)
178
- expect(@session).not_to have_css('p', maximum: 1)
189
+ # expect(@session).not_to have_css('h2.head', maximum: 4) # edge case
190
+ # expect(@session).not_to have_css('h2', maximum: 3)
191
+ expect(@session).not_to have_css('h2').at_most(3).times
192
+ # expect(@session).not_to have_css('p', maximum: 1)
179
193
  end
180
194
 
181
195
  it 'should coerce maximum to an integer' do
@@ -188,12 +202,14 @@ Capybara::SpecHelper.spec '#has_css?' do
188
202
  it 'should be true when content occurs same or more times than given' do
189
203
  expect(@session).to have_css('h2.head', minimum: 5) # edge case
190
204
  expect(@session).to have_css('h2', minimum: 3)
205
+ expect(@session).to have_css('h2').at_least(2).times
191
206
  expect(@session).to have_css('p a.doesnotexist', minimum: 0)
192
207
  end
193
208
 
194
209
  it 'should be false when content occurs fewer times than given' do
195
210
  expect(@session).not_to have_css('h2.head', minimum: 6) # edge case
196
211
  expect(@session).not_to have_css('h2', minimum: 8)
212
+ expect(@session).not_to have_css('h2').at_least(8).times
197
213
  expect(@session).not_to have_css('p', minimum: 10)
198
214
  expect(@session).not_to have_css('p a.doesnotexist', minimum: 1)
199
215
  end
@@ -216,6 +232,27 @@ Capybara::SpecHelper.spec '#has_css?' do
216
232
  end
217
233
  end
218
234
 
235
+ context 'with spatial requirements', requires: [:spatial] do
236
+ before do
237
+ @session.visit('/spatial')
238
+ end
239
+
240
+ let :center do
241
+ @session.find(:css, '.center')
242
+ end
243
+
244
+ it 'accepts spatial options' do
245
+ expect(@session).to have_css('div', above: center).thrice
246
+ expect(@session).to have_css('div', above: center, right_of: center).once
247
+ end
248
+
249
+ it 'supports spatial sugar' do
250
+ expect(@session).to have_css('div').left_of(center).thrice
251
+ expect(@session).to have_css('div').below(center).right_of(center).once
252
+ expect(@session).to have_css('div').near(center).exactly(8).times
253
+ end
254
+ end
255
+
219
256
  it 'should allow escapes in the CSS selector' do
220
257
  expect(@session).to have_css('p[data-random="abc\\\\def"]')
221
258
  expect(@session).to have_css("p[data-random='#{Capybara::Selector::CSS.escape('abc\def')}']")
@@ -16,8 +16,8 @@ Capybara::SpecHelper.spec '#has_current_path?' do
16
16
 
17
17
  it 'should not raise an error when non-http' do
18
18
  @session.reset_session!
19
- expect(@session.has_current_path?(/monkey/)).to eq false
20
- expect(@session.has_current_path?('/with_js')).to eq false
19
+ expect(@session.has_current_path?(/monkey/)).to be false
20
+ expect(@session.has_current_path?('/with_js')).to be false
21
21
  end
22
22
 
23
23
  it 'should handle non-escaped query options' do
@@ -75,13 +75,14 @@ Capybara::SpecHelper.spec '#has_current_path?' do
75
75
  @session.visit('/with_js?test=test')
76
76
  expect(@session).to have_current_path('/with_js?test=test')
77
77
  expect(@session).to have_current_path('/with_js', ignore_query: true)
78
- uri = ::Addressable::URI.parse(@session.current_url)
78
+ uri = Addressable::URI.parse(@session.current_url)
79
79
  uri.query = nil
80
80
  expect(@session).to have_current_path(uri.to_s, ignore_query: true)
81
81
  end
82
82
 
83
83
  it 'should not raise an exception if the current_url is nil' do
84
- allow_any_instance_of(Capybara::Session).to receive(:current_url).and_return(nil)
84
+ allow(@session).to receive(:current_url).and_return(nil)
85
+ allow(@session.page).to receive(:current_url).and_return(nil) if @session.respond_to? :page
85
86
 
86
87
  # Without ignore_query option
87
88
  expect do
@@ -93,6 +94,13 @@ Capybara::SpecHelper.spec '#has_current_path?' do
93
94
  expect(@session).to have_current_path(nil, ignore_query: true)
94
95
  end.not_to raise_exception
95
96
  end
97
+
98
+ it 'should accept a filter block that receives Addressable::URL' do
99
+ @session.visit('/with_js?a=3&b=defgh')
100
+ expect(@session).to have_current_path('/with_js', ignore_query: true) { |url|
101
+ url.query_values.keys == %w[a b]
102
+ }
103
+ end
96
104
  end
97
105
 
98
106
  Capybara::SpecHelper.spec '#has_no_current_path?' do
@@ -121,16 +129,23 @@ Capybara::SpecHelper.spec '#has_no_current_path?' do
121
129
  end
122
130
 
123
131
  it 'should not raise an exception if the current_url is nil' do
124
- allow_any_instance_of(Capybara::Session).to receive(:current_url).and_return(nil)
132
+ allow(@session).to receive(:current_url).and_return(nil)
133
+ allow(@session.page).to receive(:current_url).and_return(nil) if @session.respond_to? :page
125
134
 
126
135
  # Without ignore_query option
127
136
  expect do
128
137
  expect(@session).not_to have_current_path('/with_js')
129
- end. not_to raise_exception
138
+ end.not_to raise_exception
130
139
 
131
140
  # With ignore_query option
132
141
  expect do
133
142
  expect(@session).not_to have_current_path('/with_js', ignore_query: true)
134
- end. not_to raise_exception
143
+ end.not_to raise_exception
144
+ end
145
+
146
+ it 'should accept a filter block that receives Addressable::URL' do
147
+ expect(@session).to have_no_current_path('/with_js', ignore_query: true) { |url|
148
+ !url.query.nil?
149
+ }
135
150
  end
136
151
  end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ Capybara::SpecHelper.spec '#has_element?' do
4
+ before do
5
+ @session.visit('/with_html')
6
+ end
7
+
8
+ it 'should be true if the given element is on the page' do
9
+ expect(@session).to have_element('a', id: 'foo')
10
+ expect(@session).to have_element('a', text: 'A link', href: '/with_simple_html')
11
+ expect(@session).to have_element('a', text: :'A link', href: :'/with_simple_html')
12
+ expect(@session).to have_element('a', text: 'A link', href: %r{/with_simple_html})
13
+ expect(@session).to have_element('a', text: 'labore', target: '_self')
14
+ end
15
+
16
+ it 'should be false if the given element is not on the page' do
17
+ expect(@session).not_to have_element('a', text: 'monkey')
18
+ expect(@session).not_to have_element('a', text: 'A link', href: '/nonexistent-href')
19
+ expect(@session).not_to have_element('a', text: 'A link', href: /nonexistent/)
20
+ expect(@session).not_to have_element('a', text: 'labore', target: '_blank')
21
+ end
22
+
23
+ it 'should notify if an invalid locator is specified' do
24
+ allow(Capybara::Helpers).to receive(:warn).and_return(nil)
25
+ @session.has_element?(@session)
26
+ expect(Capybara::Helpers).to have_received(:warn).with(/Called from: .+/)
27
+ end
28
+ end
29
+
30
+ Capybara::SpecHelper.spec '#has_no_element?' do
31
+ before do
32
+ @session.visit('/with_html')
33
+ end
34
+
35
+ it 'should be false if the given element is on the page' do
36
+ expect(@session).not_to have_no_element('a', id: 'foo')
37
+ expect(@session).not_to have_no_element('a', text: 'A link', href: '/with_simple_html')
38
+ expect(@session).not_to have_no_element('a', text: 'labore', target: '_self')
39
+ end
40
+
41
+ it 'should be true if the given element is not on the page' do
42
+ expect(@session).to have_no_element('a', text: 'monkey')
43
+ expect(@session).to have_no_element('a', text: 'A link', href: '/nonexistent-href')
44
+ expect(@session).to have_no_element('a', text: 'A link', href: %r{/nonexistent-href})
45
+ expect(@session).to have_no_element('a', text: 'labore', target: '_blank')
46
+ end
47
+ end
@@ -60,6 +60,22 @@ Capybara::SpecHelper.spec '#has_field' do
60
60
  end
61
61
  end
62
62
 
63
+ context 'with validation message', requires: [:html_validation] do
64
+ it 'should accept a regexp' do
65
+ @session.fill_in('form_zipcode', with: '1234')
66
+ expect(@session).to have_field('form_zipcode', validation_message: /match the requested format/)
67
+ expect(@session).not_to have_field('form_zipcode', validation_message: /random/)
68
+ end
69
+
70
+ it 'should accept a string' do
71
+ @session.fill_in('form_zipcode', with: '1234')
72
+ expect(@session).to have_field('form_zipcode', validation_message: 'Please match the requested format.')
73
+ expect(@session).not_to have_field('form_zipcode', validation_message: 'match the requested format.')
74
+ @session.fill_in('form_zipcode', with: '12345')
75
+ expect(@session).to have_field('form_zipcode', validation_message: '')
76
+ end
77
+ end
78
+
63
79
  context 'with type' do
64
80
  it 'should be true if a field with the given type is on the page' do
65
81
  expect(@session).to have_field('First Name', type: 'text')
@@ -93,6 +109,36 @@ Capybara::SpecHelper.spec '#has_field' do
93
109
  expect(@session).not_to have_field('Html5 Multiple Email', multiple: false)
94
110
  end
95
111
  end
112
+
113
+ context 'with focused:', requires: [:active_element] do
114
+ it 'should be true if a field has focus' do
115
+ 2.times { @session.send_keys(:tab) }
116
+
117
+ expect(@session).to have_field('An Input', focused: true)
118
+ end
119
+
120
+ it 'should be false if a field does not have focus' do
121
+ expect(@session).to have_field('An Input', focused: false)
122
+ end
123
+ end
124
+
125
+ context 'with valid', requires: [:js] do
126
+ it 'should be true if field is valid' do
127
+ @session.fill_in 'required', with: 'something'
128
+ @session.fill_in 'length', with: 'abcd'
129
+
130
+ expect(@session).to have_field('required', valid: true)
131
+ expect(@session).to have_field('length', valid: true)
132
+ end
133
+
134
+ it 'should be false if field is invalid' do
135
+ expect(@session).not_to have_field('required', valid: true)
136
+ expect(@session).to have_field('required', valid: false)
137
+
138
+ @session.fill_in 'length', with: 'abc'
139
+ expect(@session).not_to have_field('length', valid: true)
140
+ end
141
+ end
96
142
  end
97
143
 
98
144
  Capybara::SpecHelper.spec '#has_no_field' do
@@ -150,6 +196,18 @@ Capybara::SpecHelper.spec '#has_no_field' do
150
196
  expect(@session).to have_no_field('Languages', type: 'textarea')
151
197
  end
152
198
  end
199
+
200
+ context 'with focused:', requires: [:active_element] do
201
+ it 'should be true if a field does not have focus when focused: true' do
202
+ expect(@session).to have_no_field('An Input', focused: true)
203
+ end
204
+
205
+ it 'should be false if a field has focus when focused: true' do
206
+ 2.times { @session.send_keys(:tab) }
207
+
208
+ expect(@session).not_to have_no_field('An Input', focused: true)
209
+ end
210
+ end
153
211
  end
154
212
 
155
213
  Capybara::SpecHelper.spec '#has_checked_field?' do
@@ -325,7 +383,7 @@ Capybara::SpecHelper.spec '#has_no_unchecked_field?' do
325
383
  end
326
384
 
327
385
  it 'should support locator-less usage' do
328
- expect(@session.has_no_unchecked_field?(disabled: false, id: 'form_disabled_unchecked_checkbox')).to eq true
386
+ expect(@session.has_no_unchecked_field?(disabled: false, id: 'form_disabled_unchecked_checkbox')).to be true
329
387
  expect(@session).to have_no_unchecked_field(disabled: false, id: 'form_disabled_unchecked_checkbox')
330
388
  end
331
389
  end
@@ -11,12 +11,38 @@ Capybara::SpecHelper.spec '#has_link?' do
11
11
  expect(@session).to have_link('A link', href: '/with_simple_html')
12
12
  expect(@session).to have_link(:'A link', href: :'/with_simple_html')
13
13
  expect(@session).to have_link('A link', href: %r{/with_simple_html})
14
+ expect(@session).to have_link('labore', target: '_self')
14
15
  end
15
16
 
16
17
  it 'should be false if the given link is not on the page' do
17
18
  expect(@session).not_to have_link('monkey')
18
19
  expect(@session).not_to have_link('A link', href: '/nonexistent-href')
19
20
  expect(@session).not_to have_link('A link', href: /nonexistent/)
21
+ expect(@session).not_to have_link('labore', target: '_blank')
22
+ end
23
+
24
+ it 'should notify if an invalid locator is specified' do
25
+ allow(Capybara::Helpers).to receive(:warn).and_return(nil)
26
+ @session.has_link?(@session)
27
+ expect(Capybara::Helpers).to have_received(:warn).with(/Called from: .+/)
28
+ end
29
+
30
+ context 'with focused:', requires: [:active_element] do
31
+ it 'should be true if the given link is on the page and has focus' do
32
+ @session.send_keys(:tab)
33
+
34
+ expect(@session).to have_link('labore', focused: true)
35
+ end
36
+
37
+ it 'should be false if the given link is on the page and does not have focus' do
38
+ expect(@session).to have_link('labore', focused: false)
39
+ end
40
+ end
41
+
42
+ it 'should raise an error if an invalid option is passed' do
43
+ expect do
44
+ expect(@session).to have_link('labore', invalid: true)
45
+ end.to raise_error(ArgumentError, 'Invalid option(s) :invalid, should be one of :above, :below, :left_of, :right_of, :near, :count, :minimum, :maximum, :between, :text, :id, :class, :style, :visible, :obscured, :exact, :exact_text, :normalize_ws, :match, :wait, :filter_set, :focused, :href, :alt, :title, :target, :download')
20
46
  end
21
47
  end
22
48
 
@@ -29,11 +55,25 @@ Capybara::SpecHelper.spec '#has_no_link?' do
29
55
  expect(@session).not_to have_no_link('foo')
30
56
  expect(@session).not_to have_no_link('awesome title')
31
57
  expect(@session).not_to have_no_link('A link', href: '/with_simple_html')
58
+ expect(@session).not_to have_no_link('labore', target: '_self')
32
59
  end
33
60
 
34
61
  it 'should be true if the given link is not on the page' do
35
62
  expect(@session).to have_no_link('monkey')
36
63
  expect(@session).to have_no_link('A link', href: '/nonexistent-href')
37
64
  expect(@session).to have_no_link('A link', href: %r{/nonexistent-href})
65
+ expect(@session).to have_no_link('labore', target: '_blank')
66
+ end
67
+
68
+ context 'with focused:', requires: [:active_element] do
69
+ it 'should be true if the given link is on the page and has focus' do
70
+ expect(@session).to have_no_link('labore', focused: true)
71
+ end
72
+
73
+ it 'should be false if the given link is on the page and does not have focus' do
74
+ @session.send_keys(:tab)
75
+
76
+ expect(@session).to have_no_link('labore', focused: false)
77
+ end
38
78
  end
39
79
  end
@@ -8,10 +8,10 @@ Capybara::SpecHelper.spec '#have_none_of_selectors' do
8
8
  it 'should be false if any of the given locators are on the page' do
9
9
  expect do
10
10
  expect(@session).to have_none_of_selectors(:xpath, '//p', '//a')
11
- end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
11
+ end.to raise_error RSpec::Expectations::ExpectationNotMetError
12
12
  expect do
13
13
  expect(@session).to have_none_of_selectors(:css, 'p a#foo')
14
- end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
14
+ end.to raise_error RSpec::Expectations::ExpectationNotMetError
15
15
  end
16
16
 
17
17
  it 'should be true if none of the given locators are on the page' do
@@ -24,7 +24,7 @@ Capybara::SpecHelper.spec '#have_none_of_selectors' do
24
24
  expect(@session).to have_none_of_selectors('p a#doesnotexist', 'abbr')
25
25
  expect do
26
26
  expect(@session).to have_none_of_selectors('abbr', 'p a#foo')
27
- end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
27
+ end.to raise_error RSpec::Expectations::ExpectationNotMetError
28
28
  end
29
29
 
30
30
  context 'should respect scopes' do
@@ -32,7 +32,7 @@ Capybara::SpecHelper.spec '#have_none_of_selectors' do
32
32
  @session.within "//p[@id='first']" do
33
33
  expect do
34
34
  expect(@session).to have_none_of_selectors(".//a[@id='foo']")
35
- end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
35
+ end.to raise_error RSpec::Expectations::ExpectationNotMetError
36
36
  expect(@session).to have_none_of_selectors(".//a[@id='red']")
37
37
  end
38
38
  end
@@ -41,7 +41,7 @@ Capybara::SpecHelper.spec '#have_none_of_selectors' do
41
41
  el = @session.find "//p[@id='first']"
42
42
  expect do
43
43
  expect(el).to have_none_of_selectors(".//a[@id='foo']")
44
- end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
44
+ end.to raise_error RSpec::Expectations::ExpectationNotMetError
45
45
  expect(el).to have_none_of_selectors(".//a[@id='red']")
46
46
  end
47
47
  end
@@ -50,14 +50,14 @@ Capybara::SpecHelper.spec '#have_none_of_selectors' do
50
50
  it 'should apply the options to all locators' do
51
51
  expect do
52
52
  expect(@session).to have_none_of_selectors('//p//a', text: 'Redirect')
53
- end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
53
+ end.to raise_error RSpec::Expectations::ExpectationNotMetError
54
54
  expect(@session).to have_none_of_selectors('//p', text: 'Doesnotexist')
55
55
  end
56
56
 
57
57
  it 'should discard all matches where the given regexp is matched' do
58
58
  expect do
59
59
  expect(@session).to have_none_of_selectors('//p//a', text: /re[dab]i/i, count: 1)
60
- end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
60
+ end.to raise_error RSpec::Expectations::ExpectationNotMetError
61
61
  expect(@session).to have_none_of_selectors('//p//a', text: /Red$/)
62
62
  end
63
63
  end