capybara 2.18.0 → 3.38.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (315) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -1
  3. data/History.md +889 -12
  4. data/License.txt +1 -1
  5. data/README.md +108 -78
  6. data/lib/capybara/config.rb +29 -57
  7. data/lib/capybara/cucumber.rb +2 -3
  8. data/lib/capybara/driver/base.rb +35 -18
  9. data/lib/capybara/driver/node.rb +40 -10
  10. data/lib/capybara/dsl.rb +10 -7
  11. data/lib/capybara/helpers.rb +70 -31
  12. data/lib/capybara/minitest/spec.rb +173 -83
  13. data/lib/capybara/minitest.rb +219 -112
  14. data/lib/capybara/node/actions.rb +274 -171
  15. data/lib/capybara/node/base.rb +42 -34
  16. data/lib/capybara/node/document.rb +15 -3
  17. data/lib/capybara/node/document_matchers.rb +19 -21
  18. data/lib/capybara/node/element.rb +362 -135
  19. data/lib/capybara/node/finders.rb +149 -137
  20. data/lib/capybara/node/matchers.rb +369 -209
  21. data/lib/capybara/node/simple.rb +59 -26
  22. data/lib/capybara/queries/active_element_query.rb +18 -0
  23. data/lib/capybara/queries/ancestor_query.rb +12 -9
  24. data/lib/capybara/queries/base_query.rb +39 -28
  25. data/lib/capybara/queries/current_path_query.rb +21 -27
  26. data/lib/capybara/queries/match_query.rb +14 -7
  27. data/lib/capybara/queries/selector_query.rb +658 -149
  28. data/lib/capybara/queries/sibling_query.rb +11 -9
  29. data/lib/capybara/queries/style_query.rb +45 -0
  30. data/lib/capybara/queries/text_query.rb +56 -38
  31. data/lib/capybara/queries/title_query.rb +8 -11
  32. data/lib/capybara/rack_test/browser.rb +113 -42
  33. data/lib/capybara/rack_test/css_handlers.rb +6 -4
  34. data/lib/capybara/rack_test/driver.rb +22 -17
  35. data/lib/capybara/rack_test/errors.rb +6 -0
  36. data/lib/capybara/rack_test/form.rb +93 -58
  37. data/lib/capybara/rack_test/node.rb +188 -81
  38. data/lib/capybara/rails.rb +3 -7
  39. data/lib/capybara/registration_container.rb +41 -0
  40. data/lib/capybara/registrations/drivers.rb +42 -0
  41. data/lib/capybara/registrations/patches/puma_ssl.rb +29 -0
  42. data/lib/capybara/registrations/servers.rb +53 -0
  43. data/lib/capybara/result.rb +96 -62
  44. data/lib/capybara/rspec/features.rb +17 -50
  45. data/lib/capybara/rspec/matcher_proxies.rb +52 -15
  46. data/lib/capybara/rspec/matchers/base.rb +111 -0
  47. data/lib/capybara/rspec/matchers/become_closed.rb +33 -0
  48. data/lib/capybara/rspec/matchers/compound.rb +88 -0
  49. data/lib/capybara/rspec/matchers/count_sugar.rb +37 -0
  50. data/lib/capybara/rspec/matchers/have_ancestor.rb +28 -0
  51. data/lib/capybara/rspec/matchers/have_current_path.rb +29 -0
  52. data/lib/capybara/rspec/matchers/have_selector.rb +77 -0
  53. data/lib/capybara/rspec/matchers/have_sibling.rb +27 -0
  54. data/lib/capybara/rspec/matchers/have_text.rb +33 -0
  55. data/lib/capybara/rspec/matchers/have_title.rb +29 -0
  56. data/lib/capybara/rspec/matchers/match_selector.rb +27 -0
  57. data/lib/capybara/rspec/matchers/match_style.rb +43 -0
  58. data/lib/capybara/rspec/matchers/spatial_sugar.rb +39 -0
  59. data/lib/capybara/rspec/matchers.rb +142 -311
  60. data/lib/capybara/rspec.rb +7 -11
  61. data/lib/capybara/selector/builders/css_builder.rb +84 -0
  62. data/lib/capybara/selector/builders/xpath_builder.rb +71 -0
  63. data/lib/capybara/selector/css.rb +89 -17
  64. data/lib/capybara/selector/definition/button.rb +68 -0
  65. data/lib/capybara/selector/definition/checkbox.rb +26 -0
  66. data/lib/capybara/selector/definition/css.rb +10 -0
  67. data/lib/capybara/selector/definition/datalist_input.rb +35 -0
  68. data/lib/capybara/selector/definition/datalist_option.rb +25 -0
  69. data/lib/capybara/selector/definition/element.rb +28 -0
  70. data/lib/capybara/selector/definition/field.rb +40 -0
  71. data/lib/capybara/selector/definition/fieldset.rb +14 -0
  72. data/lib/capybara/selector/definition/file_field.rb +13 -0
  73. data/lib/capybara/selector/definition/fillable_field.rb +33 -0
  74. data/lib/capybara/selector/definition/frame.rb +17 -0
  75. data/lib/capybara/selector/definition/id.rb +6 -0
  76. data/lib/capybara/selector/definition/label.rb +62 -0
  77. data/lib/capybara/selector/definition/link.rb +54 -0
  78. data/lib/capybara/selector/definition/link_or_button.rb +16 -0
  79. data/lib/capybara/selector/definition/option.rb +27 -0
  80. data/lib/capybara/selector/definition/radio_button.rb +27 -0
  81. data/lib/capybara/selector/definition/select.rb +81 -0
  82. data/lib/capybara/selector/definition/table.rb +109 -0
  83. data/lib/capybara/selector/definition/table_row.rb +21 -0
  84. data/lib/capybara/selector/definition/xpath.rb +5 -0
  85. data/lib/capybara/selector/definition.rb +280 -0
  86. data/lib/capybara/selector/filter.rb +2 -17
  87. data/lib/capybara/selector/filter_set.rb +80 -33
  88. data/lib/capybara/selector/filters/base.rb +50 -6
  89. data/lib/capybara/selector/filters/expression_filter.rb +8 -26
  90. data/lib/capybara/selector/filters/locator_filter.rb +29 -0
  91. data/lib/capybara/selector/filters/node_filter.rb +16 -12
  92. data/lib/capybara/selector/regexp_disassembler.rb +211 -0
  93. data/lib/capybara/selector/selector.rb +93 -210
  94. data/lib/capybara/selector/xpath_extensions.rb +17 -0
  95. data/lib/capybara/selector.rb +227 -526
  96. data/lib/capybara/selenium/atoms/getAttribute.min.js +1 -0
  97. data/lib/capybara/selenium/atoms/isDisplayed.min.js +1 -0
  98. data/lib/capybara/selenium/atoms/src/getAttribute.js +161 -0
  99. data/lib/capybara/selenium/atoms/src/isDisplayed.js +454 -0
  100. data/lib/capybara/selenium/driver.rb +332 -261
  101. data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +117 -0
  102. data/lib/capybara/selenium/driver_specializations/edge_driver.rb +124 -0
  103. data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +89 -0
  104. data/lib/capybara/selenium/driver_specializations/internet_explorer_driver.rb +26 -0
  105. data/lib/capybara/selenium/driver_specializations/safari_driver.rb +24 -0
  106. data/lib/capybara/selenium/extensions/file_input_click_emulation.rb +34 -0
  107. data/lib/capybara/selenium/extensions/find.rb +110 -0
  108. data/lib/capybara/selenium/extensions/html5_drag.rb +226 -0
  109. data/lib/capybara/selenium/extensions/modifier_keys_stack.rb +28 -0
  110. data/lib/capybara/selenium/extensions/scroll.rb +76 -0
  111. data/lib/capybara/selenium/logger_suppressor.rb +44 -0
  112. data/lib/capybara/selenium/node.rb +545 -144
  113. data/lib/capybara/selenium/nodes/chrome_node.rb +137 -0
  114. data/lib/capybara/selenium/nodes/edge_node.rb +104 -0
  115. data/lib/capybara/selenium/nodes/firefox_node.rb +136 -0
  116. data/lib/capybara/selenium/nodes/ie_node.rb +22 -0
  117. data/lib/capybara/selenium/nodes/safari_node.rb +118 -0
  118. data/lib/capybara/selenium/patches/action_pauser.rb +26 -0
  119. data/lib/capybara/selenium/patches/atoms.rb +18 -0
  120. data/lib/capybara/selenium/patches/is_displayed.rb +16 -0
  121. data/lib/capybara/selenium/patches/logs.rb +45 -0
  122. data/lib/capybara/selenium/patches/pause_duration_fix.rb +9 -0
  123. data/lib/capybara/selenium/patches/persistent_client.rb +20 -0
  124. data/lib/capybara/server/animation_disabler.rb +81 -0
  125. data/lib/capybara/server/checker.rb +44 -0
  126. data/lib/capybara/server/middleware.rb +71 -0
  127. data/lib/capybara/server.rb +59 -67
  128. data/lib/capybara/session/config.rb +81 -67
  129. data/lib/capybara/session/matchers.rb +28 -20
  130. data/lib/capybara/session.rb +336 -365
  131. data/lib/capybara/spec/public/jquery.js +5 -5
  132. data/lib/capybara/spec/public/offset.js +6 -0
  133. data/lib/capybara/spec/public/test.js +147 -12
  134. data/lib/capybara/spec/session/accept_alert_spec.rb +12 -11
  135. data/lib/capybara/spec/session/accept_confirm_spec.rb +6 -5
  136. data/lib/capybara/spec/session/accept_prompt_spec.rb +10 -10
  137. data/lib/capybara/spec/session/active_element_spec.rb +31 -0
  138. data/lib/capybara/spec/session/all_spec.rb +160 -56
  139. data/lib/capybara/spec/session/ancestor_spec.rb +27 -24
  140. data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +68 -38
  141. data/lib/capybara/spec/session/assert_current_path_spec.rb +75 -0
  142. data/lib/capybara/spec/session/assert_selector_spec.rb +143 -0
  143. data/lib/capybara/spec/session/assert_style_spec.rb +26 -0
  144. data/lib/capybara/spec/session/assert_text_spec.rb +258 -0
  145. data/lib/capybara/spec/session/{assert_title.rb → assert_title_spec.rb} +22 -12
  146. data/lib/capybara/spec/session/attach_file_spec.rb +144 -69
  147. data/lib/capybara/spec/session/body_spec.rb +12 -13
  148. data/lib/capybara/spec/session/check_spec.rb +117 -55
  149. data/lib/capybara/spec/session/choose_spec.rb +64 -31
  150. data/lib/capybara/spec/session/click_button_spec.rb +231 -173
  151. data/lib/capybara/spec/session/click_link_or_button_spec.rb +55 -35
  152. data/lib/capybara/spec/session/click_link_spec.rb +82 -58
  153. data/lib/capybara/spec/session/current_scope_spec.rb +12 -11
  154. data/lib/capybara/spec/session/current_url_spec.rb +57 -39
  155. data/lib/capybara/spec/session/dismiss_confirm_spec.rb +4 -4
  156. data/lib/capybara/spec/session/dismiss_prompt_spec.rb +3 -2
  157. data/lib/capybara/spec/session/element/{assert_match_selector.rb → assert_match_selector_spec.rb} +11 -9
  158. data/lib/capybara/spec/session/element/match_css_spec.rb +18 -10
  159. data/lib/capybara/spec/session/element/match_xpath_spec.rb +9 -7
  160. data/lib/capybara/spec/session/element/matches_selector_spec.rb +71 -57
  161. data/lib/capybara/spec/session/evaluate_async_script_spec.rb +8 -7
  162. data/lib/capybara/spec/session/evaluate_script_spec.rb +29 -8
  163. data/lib/capybara/spec/session/execute_script_spec.rb +10 -8
  164. data/lib/capybara/spec/session/fill_in_spec.rb +134 -43
  165. data/lib/capybara/spec/session/find_button_spec.rb +25 -24
  166. data/lib/capybara/spec/session/find_by_id_spec.rb +10 -9
  167. data/lib/capybara/spec/session/find_field_spec.rb +37 -41
  168. data/lib/capybara/spec/session/find_link_spec.rb +36 -17
  169. data/lib/capybara/spec/session/find_spec.rb +251 -144
  170. data/lib/capybara/spec/session/first_spec.rb +79 -51
  171. data/lib/capybara/spec/session/frame/frame_title_spec.rb +23 -0
  172. data/lib/capybara/spec/session/frame/frame_url_spec.rb +23 -0
  173. data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +33 -20
  174. data/lib/capybara/spec/session/frame/within_frame_spec.rb +50 -32
  175. data/lib/capybara/spec/session/go_back_spec.rb +2 -1
  176. data/lib/capybara/spec/session/go_forward_spec.rb +2 -1
  177. data/lib/capybara/spec/session/has_all_selectors_spec.rb +31 -31
  178. data/lib/capybara/spec/session/has_ancestor_spec.rb +46 -0
  179. data/lib/capybara/spec/session/has_any_selectors_spec.rb +29 -0
  180. data/lib/capybara/spec/session/has_button_spec.rb +100 -13
  181. data/lib/capybara/spec/session/has_css_spec.rb +272 -137
  182. data/lib/capybara/spec/session/has_current_path_spec.rb +59 -60
  183. data/lib/capybara/spec/session/has_field_spec.rb +139 -59
  184. data/lib/capybara/spec/session/has_link_spec.rb +43 -6
  185. data/lib/capybara/spec/session/has_none_selectors_spec.rb +42 -40
  186. data/lib/capybara/spec/session/has_select_spec.rb +107 -72
  187. data/lib/capybara/spec/session/has_selector_spec.rb +120 -71
  188. data/lib/capybara/spec/session/has_sibling_spec.rb +50 -0
  189. data/lib/capybara/spec/session/has_table_spec.rb +172 -5
  190. data/lib/capybara/spec/session/has_text_spec.rb +106 -62
  191. data/lib/capybara/spec/session/has_title_spec.rb +20 -14
  192. data/lib/capybara/spec/session/has_xpath_spec.rb +57 -38
  193. data/lib/capybara/spec/session/{headers.rb → headers_spec.rb} +3 -2
  194. data/lib/capybara/spec/session/html_spec.rb +14 -6
  195. data/lib/capybara/spec/session/matches_style_spec.rb +35 -0
  196. data/lib/capybara/spec/session/node_spec.rb +1002 -153
  197. data/lib/capybara/spec/session/node_wrapper_spec.rb +39 -0
  198. data/lib/capybara/spec/session/refresh_spec.rb +12 -6
  199. data/lib/capybara/spec/session/reset_session_spec.rb +82 -35
  200. data/lib/capybara/spec/session/{response_code.rb → response_code_spec.rb} +2 -1
  201. data/lib/capybara/spec/session/save_and_open_page_spec.rb +3 -2
  202. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +8 -12
  203. data/lib/capybara/spec/session/save_page_spec.rb +42 -55
  204. data/lib/capybara/spec/session/save_screenshot_spec.rb +16 -14
  205. data/lib/capybara/spec/session/screenshot_spec.rb +2 -2
  206. data/lib/capybara/spec/session/scroll_spec.rb +117 -0
  207. data/lib/capybara/spec/session/select_spec.rb +107 -81
  208. data/lib/capybara/spec/session/selectors_spec.rb +52 -19
  209. data/lib/capybara/spec/session/sibling_spec.rb +10 -10
  210. data/lib/capybara/spec/session/text_spec.rb +37 -21
  211. data/lib/capybara/spec/session/title_spec.rb +17 -5
  212. data/lib/capybara/spec/session/uncheck_spec.rb +42 -22
  213. data/lib/capybara/spec/session/unselect_spec.rb +39 -38
  214. data/lib/capybara/spec/session/visit_spec.rb +85 -53
  215. data/lib/capybara/spec/session/window/become_closed_spec.rb +24 -20
  216. data/lib/capybara/spec/session/window/current_window_spec.rb +5 -3
  217. data/lib/capybara/spec/session/window/open_new_window_spec.rb +5 -3
  218. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +27 -22
  219. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +12 -6
  220. data/lib/capybara/spec/session/window/window_spec.rb +97 -63
  221. data/lib/capybara/spec/session/window/windows_spec.rb +12 -10
  222. data/lib/capybara/spec/session/window/within_window_spec.rb +31 -86
  223. data/lib/capybara/spec/session/within_spec.rb +83 -44
  224. data/lib/capybara/spec/spec_helper.rb +53 -43
  225. data/lib/capybara/spec/test_app.rb +158 -43
  226. data/lib/capybara/spec/views/animated.erb +49 -0
  227. data/lib/capybara/spec/views/form.erb +154 -42
  228. data/lib/capybara/spec/views/frame_child.erb +4 -3
  229. data/lib/capybara/spec/views/frame_one.erb +2 -1
  230. data/lib/capybara/spec/views/frame_parent.erb +1 -1
  231. data/lib/capybara/spec/views/frame_two.erb +1 -1
  232. data/lib/capybara/spec/views/initial_alert.erb +2 -1
  233. data/lib/capybara/spec/views/layout.erb +10 -0
  234. data/lib/capybara/spec/views/obscured.erb +47 -0
  235. data/lib/capybara/spec/views/offset.erb +33 -0
  236. data/lib/capybara/spec/views/path.erb +2 -2
  237. data/lib/capybara/spec/views/popup_one.erb +1 -1
  238. data/lib/capybara/spec/views/popup_two.erb +1 -1
  239. data/lib/capybara/spec/views/react.erb +45 -0
  240. data/lib/capybara/spec/views/scroll.erb +21 -0
  241. data/lib/capybara/spec/views/spatial.erb +31 -0
  242. data/lib/capybara/spec/views/tables.erb +68 -1
  243. data/lib/capybara/spec/views/with_animation.erb +81 -0
  244. data/lib/capybara/spec/views/with_base_tag.erb +2 -2
  245. data/lib/capybara/spec/views/with_dragula.erb +24 -0
  246. data/lib/capybara/spec/views/with_fixed_header_footer.erb +2 -1
  247. data/lib/capybara/spec/views/with_hover.erb +3 -2
  248. data/lib/capybara/spec/views/with_hover1.erb +10 -0
  249. data/lib/capybara/spec/views/with_html.erb +67 -12
  250. data/lib/capybara/spec/views/with_html5_svg.erb +20 -0
  251. data/lib/capybara/spec/views/with_jquery_animation.erb +24 -0
  252. data/lib/capybara/spec/views/with_js.erb +30 -5
  253. data/lib/capybara/spec/views/with_jstree.erb +26 -0
  254. data/lib/capybara/spec/views/with_namespace.erb +21 -0
  255. data/lib/capybara/spec/views/with_scope.erb +2 -2
  256. data/lib/capybara/spec/views/with_scope_other.erb +6 -0
  257. data/lib/capybara/spec/views/with_shadow.erb +31 -0
  258. data/lib/capybara/spec/views/with_slow_unload.erb +2 -1
  259. data/lib/capybara/spec/views/with_sortable_js.erb +21 -0
  260. data/lib/capybara/spec/views/with_unload_alert.erb +1 -0
  261. data/lib/capybara/spec/views/with_windows.erb +1 -1
  262. data/lib/capybara/spec/views/within_frames.erb +5 -2
  263. data/lib/capybara/version.rb +2 -1
  264. data/lib/capybara/window.rb +36 -34
  265. data/lib/capybara.rb +129 -103
  266. data/spec/basic_node_spec.rb +60 -34
  267. data/spec/capybara_spec.rb +63 -88
  268. data/spec/counter_spec.rb +35 -0
  269. data/spec/css_builder_spec.rb +101 -0
  270. data/spec/css_splitter_spec.rb +38 -0
  271. data/spec/dsl_spec.rb +85 -64
  272. data/spec/filter_set_spec.rb +27 -9
  273. data/spec/fixtures/certificate.pem +25 -0
  274. data/spec/fixtures/key.pem +27 -0
  275. data/spec/fixtures/selenium_driver_rspec_failure.rb +6 -5
  276. data/spec/fixtures/selenium_driver_rspec_success.rb +6 -5
  277. data/spec/minitest_spec.rb +45 -7
  278. data/spec/minitest_spec_spec.rb +94 -63
  279. data/spec/per_session_config_spec.rb +14 -13
  280. data/spec/rack_test_spec.rb +194 -125
  281. data/spec/regexp_dissassembler_spec.rb +250 -0
  282. data/spec/result_spec.rb +102 -50
  283. data/spec/rspec/features_spec.rb +37 -31
  284. data/spec/rspec/scenarios_spec.rb +9 -7
  285. data/spec/rspec/shared_spec_matchers.rb +449 -422
  286. data/spec/rspec/views_spec.rb +5 -3
  287. data/spec/rspec_matchers_spec.rb +27 -11
  288. data/spec/rspec_spec.rb +109 -89
  289. data/spec/sauce_spec_chrome.rb +43 -0
  290. data/spec/selector_spec.rb +397 -68
  291. data/spec/selenium_spec_chrome.rb +186 -40
  292. data/spec/selenium_spec_chrome_remote.rb +103 -0
  293. data/spec/selenium_spec_edge.rb +49 -0
  294. data/spec/selenium_spec_firefox.rb +194 -41
  295. data/spec/selenium_spec_firefox_remote.rb +82 -0
  296. data/spec/selenium_spec_ie.rb +149 -0
  297. data/spec/selenium_spec_safari.rb +162 -0
  298. data/spec/server_spec.rb +201 -102
  299. data/spec/session_spec.rb +53 -16
  300. data/spec/shared_selenium_node.rb +79 -0
  301. data/spec/shared_selenium_session.rb +474 -122
  302. data/spec/spec_helper.rb +93 -7
  303. data/spec/xpath_builder_spec.rb +93 -0
  304. metadata +360 -73
  305. data/.yard/templates_custom/default/class/html/selectors.erb +0 -38
  306. data/.yard/templates_custom/default/class/html/setup.rb +0 -17
  307. data/.yard/yard_extensions.rb +0 -78
  308. data/lib/capybara/query.rb +0 -7
  309. data/lib/capybara/rspec/compound.rb +0 -95
  310. data/lib/capybara/spec/session/assert_current_path.rb +0 -72
  311. data/lib/capybara/spec/session/assert_selector.rb +0 -148
  312. data/lib/capybara/spec/session/assert_text.rb +0 -234
  313. data/lib/capybara/spec/session/source_spec.rb +0 -0
  314. data/lib/capybara/spec/views/with_title.erb +0 -5
  315. data/spec/selenium_spec_marionette.rb +0 -127
data/License.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2009-2016 Jonas Nicklas
3
+ Copyright (c) 2009-2018 Thomas Walpole, Jonas Nicklas
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # Capybara
2
2
 
3
3
  [![Build Status](https://secure.travis-ci.org/teamcapybara/capybara.svg)](https://travis-ci.org/teamcapybara/capybara)
4
- [![Dependency Status](https://gemnasium.com/teamcapybara/capybara.svg)](https://gemnasium.com/teamcapybara/capybara)
4
+ [![Build Status](https://ci.appveyor.com/api/projects/status/github/teamcapybara/capybara?svg=true)](https://ci.appveyor.com/api/projects/github/teamcapybara/capybara)
5
5
  [![Code Climate](https://codeclimate.com/github/teamcapybara/capybara.svg)](https://codeclimate.com/github/teamcapybara/capybara)
6
+ [![Coverage Status](https://coveralls.io/repos/github/teamcapybara/capybara/badge.svg?branch=master)](https://coveralls.io/github/teamcapybara/capybara?branch=master)
6
7
  [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jnicklas/capybara?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8
+ [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=capybara&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=capybara&package-manager=bundler&version-scheme=semver)
7
9
 
8
10
  Capybara helps you test web applications by simulating how a real user would
9
11
  interact with your app. It is agnostic about the driver running your tests and
@@ -32,8 +34,7 @@ GitHub): http://groups.google.com/group/ruby-capybara
32
34
  - [Selecting the Driver](#selecting-the-driver)
33
35
  - [RackTest](#racktest)
34
36
  - [Selenium](#selenium)
35
- - [Capybara-webkit](#capybara-webkit)
36
- - [Poltergeist](#poltergeist)
37
+ - [Apparition](#apparition)
37
38
  - [The DSL](#the-dsl)
38
39
  - [Navigating](#navigating)
39
40
  - [Clicking links and buttons](#clicking-links-and-buttons)
@@ -53,11 +54,13 @@ GitHub): http://groups.google.com/group/ruby-capybara
53
54
  - [Using the DSL elsewhere](#using-the-dsl-elsewhere)
54
55
  - [Calling remote servers](#calling-remote-servers)
55
56
  - [Using sessions](#using-sessions)
57
+ - [Named sessions](#named-sessions)
58
+ - [Using sessions manually](#using-sessions-manually)
56
59
  - [XPath, CSS and selectors](#xpath-css-and-selectors)
57
60
  - [Beware the XPath // trap](#beware-the-xpath--trap)
58
61
  - [Configuring and adding drivers](#configuring-and-adding-drivers)
59
62
  - [Gotchas:](#gotchas)
60
- - ["Threadsafe" mode](#threadsafe)
63
+ - ["Threadsafe" mode](#threadsafe-mode)
61
64
  - [Development](#development)
62
65
 
63
66
  ## <a name="key-benefits"></a>Key benefits
@@ -71,24 +74,19 @@ GitHub): http://groups.google.com/group/ruby-capybara
71
74
 
72
75
  ## <a name="setup"></a>Setup
73
76
 
74
- Capybara requires Ruby 1.9.3 or later. To install, add this line to your
77
+ Capybara requires Ruby 2.7.0 or later. To install, add this line to your
75
78
  `Gemfile` and run `bundle install`:
76
79
 
77
80
  ```ruby
78
81
  gem 'capybara'
79
82
  ```
80
83
 
81
- **Note:** If using Ruby < 2.0 you will also need to limit the version of rack to < 2.0
82
-
83
84
  If the application that you are testing is a Rails app, add this line to your test helper file:
84
85
 
85
86
  ```ruby
86
87
  require 'capybara/rails'
87
88
  ```
88
89
 
89
- **Note:** In Rails 4.0/4.1 the default test environment (`config/environments/test.rb`) is [not threadsafe](https://github.com/rails/rails/issues/15089).
90
- If you experience random errors about missing constants, add `config.allow_concurrency = false` to `config/environments/test.rb`.
91
-
92
90
  If the application that you are testing is a Rack app, but not Rails, set Capybara.app to your Rack app:
93
91
 
94
92
  ```ruby
@@ -140,28 +138,30 @@ There are also explicit tags for each registered driver set up for you (`@seleni
140
138
 
141
139
  ## <a name="using-capybara-with-rspec"></a>Using Capybara with RSpec
142
140
 
143
- Load RSpec 2+ support by adding the following line (typically to your
141
+ Load RSpec 3.5+ support by adding the following line (typically to your
144
142
  `spec_helper.rb` file):
145
143
 
146
144
  ```ruby
147
145
  require 'capybara/rspec'
148
146
  ```
149
147
 
150
- If you are using Rails, put your Capybara specs in `spec/features` (only works
148
+ If you are using Rails, put your Capybara specs in `spec/features` or `spec/system` (only works
151
149
  if [you have it configured in
152
- RSpec](https://www.relishapp.com/rspec/rspec-rails/docs/upgrade#file-type-inference-disabled))
150
+ RSpec](https://relishapp.com/rspec/rspec-rails/v/4-0/docs/directory-structure))
153
151
  and if you have your Capybara specs in a different directory, then tag the
154
- example groups with `:type => :feature`.
152
+ example groups with `type: :feature` or `type: :system` depending on which type of test you're writing.
153
+
154
+ If you are using Rails system specs please see [their documentation](https://relishapp.com/rspec/rspec-rails/docs/system-specs/system-spec#system-specs-driven-by-selenium-chrome-headless) for selecting the driver you wish to use.
155
155
 
156
156
  If you are not using Rails, tag all the example groups in which you want to use
157
- Capybara with `:type => :feature`.
157
+ Capybara with `type: :feature`.
158
158
 
159
159
  You can now write your specs like so:
160
160
 
161
161
  ```ruby
162
- describe "the signin process", :type => :feature do
162
+ describe "the signin process", type: :feature do
163
163
  before :each do
164
- User.make(email: 'user@example.com', password: 'password')
164
+ User.create(email: 'user@example.com', password: 'password')
165
165
  end
166
166
 
167
167
  it "signs me in" do
@@ -183,7 +183,7 @@ to one specific driver. For example:
183
183
  ```ruby
184
184
  describe 'some stuff which requires js', js: true do
185
185
  it 'will use the default js driver'
186
- it 'will switch to one specific driver', :driver => :webkit
186
+ it 'will switch to one specific driver', driver: :apparition
187
187
  end
188
188
  ```
189
189
 
@@ -192,7 +192,7 @@ Capybara also comes with a built in DSL for creating descriptive acceptance test
192
192
  ```ruby
193
193
  feature "Signing in" do
194
194
  background do
195
- User.make(email: 'user@example.com', password: 'caplin')
195
+ User.create(email: 'user@example.com', password: 'caplin')
196
196
  end
197
197
 
198
198
  scenario "Signing in with correct credentials" do
@@ -205,7 +205,7 @@ feature "Signing in" do
205
205
  expect(page).to have_content 'Success'
206
206
  end
207
207
 
208
- given(:other_user) { User.make(email: 'other@example.com', password: 'rous') }
208
+ given(:other_user) { User.create(email: 'other@example.com', password: 'rous') }
209
209
 
210
210
  scenario "Signing in as another user" do
211
211
  visit '/sessions/new'
@@ -219,11 +219,11 @@ feature "Signing in" do
219
219
  end
220
220
  ```
221
221
 
222
- `feature` is in fact just an alias for `describe ..., :type => :feature`,
222
+ `feature` is in fact just an alias for `describe ..., type: :feature`,
223
223
  `background` is an alias for `before`, `scenario` for `it`, and
224
224
  `given`/`given!` aliases for `let`/`let!`, respectively.
225
225
 
226
- Finally, Capybara matchers are supported in view specs:
226
+ Finally, Capybara matchers are also supported in view specs:
227
227
 
228
228
  ```ruby
229
229
  RSpec.describe "todos/show.html.erb", type: :view do
@@ -260,7 +260,9 @@ end
260
260
 
261
261
  ## <a name="using-capybara-with-minitest"></a>Using Capybara with Minitest
262
262
 
263
- * If you are using Rails, add the following code in your `test_helper.rb`
263
+ * If you are using Rails system tests please see their documentation for information on selecting the driver you wish to use.
264
+
265
+ * If you are using Rails, but not using Rails system tests, add the following code in your `test_helper.rb`
264
266
  file to make Capybara available in all test cases deriving from
265
267
  `ActionDispatch::IntegrationTest`:
266
268
 
@@ -275,8 +277,7 @@ end
275
277
  include Capybara::Minitest::Assertions
276
278
 
277
279
  # Reset sessions and driver between tests
278
- # Use super wherever this method is redefined in your individual test classes
279
- def teardown
280
+ teardown do
280
281
  Capybara.reset_sessions!
281
282
  Capybara.use_default_driver
282
283
  end
@@ -335,15 +336,15 @@ By default, Capybara uses the `:rack_test` driver, which is fast but limited: it
335
336
  does not support JavaScript, nor is it able to access HTTP resources outside of
336
337
  your Rack application, such as remote APIs and OAuth services. To get around
337
338
  these limitations, you can set up a different default driver for your features.
338
- For example if you'd prefer to run everything in Selenium, you could do:
339
+ For example, if you'd prefer to run everything in Selenium, you could do:
339
340
 
340
341
  ```ruby
341
342
  Capybara.default_driver = :selenium # :selenium_chrome and :selenium_chrome_headless are also registered
342
343
  ```
343
344
 
344
- However, if you are using RSpec or Cucumber, you may instead want to consider
345
- leaving the faster `:rack_test` as the __default_driver__, and marking only those
346
- tests that require a JavaScript-capable driver using `js: true` or
345
+ However, if you are using RSpec or Cucumber (and your app runs correctly without JS),
346
+ you may instead want to consider leaving the faster `:rack_test` as the __default_driver__, and
347
+ marking only those tests that require a JavaScript-capable driver using `js: true` or
347
348
  `@javascript`, respectively. By default, JavaScript tests are run using the
348
349
  `:selenium` driver. You can change this by setting
349
350
  `Capybara.javascript_driver`.
@@ -352,7 +353,7 @@ You can also change the driver temporarily (typically in the Before/setup and
352
353
  After/teardown blocks):
353
354
 
354
355
  ```ruby
355
- Capybara.current_driver = :webkit # temporarily select different driver
356
+ Capybara.current_driver = :apparition # temporarily select different driver
356
357
  # tests here
357
358
  Capybara.use_default_driver # switch back to default driver
358
359
  ```
@@ -387,42 +388,35 @@ See the section on adding and configuring drivers.
387
388
 
388
389
  ### <a name="selenium"></a>Selenium
389
390
 
390
- At the moment, Capybara supports [Selenium 2.0+
391
- (Webdriver)](http://seleniumhq.org/docs/01_introducing_selenium.html#selenium-2-aka-selenium-webdriver),
392
- *not* Selenium RC. In order to use Selenium, you'll need to install the
393
- `selenium-webdriver` gem, and add it to your Gemfile if you're using bundler.
394
- Provided Firefox is installed, everything is set up for you, and you should be
395
- able to start using Selenium right away.
391
+ Capybara supports [Selenium 3.5+
392
+ (Webdriver)](https://www.seleniumhq.org/projects/webdriver/).
393
+ In order to use Selenium, you'll need to install the `selenium-webdriver` gem,
394
+ and add it to your Gemfile if you're using bundler.
396
395
 
397
- **Note**: drivers which run the server in a different thread may not share the
398
- same transaction as your tests, causing data not to be shared between your test
399
- and test server, see "Transactions and database setup" below.
400
-
401
- ### <a name="capybara-webkit"></a>Capybara-webkit
402
-
403
- The [capybara-webkit driver](https://github.com/thoughtbot/capybara-webkit) is for true headless
404
- testing. It uses QtWebKit to start a rendering engine process. It can execute JavaScript as well.
405
- It is significantly faster than drivers like Selenium since it does not load an entire browser.
396
+ Capybara pre-registers a number of named drivers that use Selenium - they are:
406
397
 
407
- You can install it with:
398
+ * :selenium => Selenium driving Firefox
399
+ * :selenium_headless => Selenium driving Firefox in a headless configuration
400
+ * :selenium_chrome => Selenium driving Chrome
401
+ * :selenium_chrome_headless => Selenium driving Chrome in a headless configuration
408
402
 
409
- ```bash
410
- gem install capybara-webkit
411
- ```
403
+ These should work (with relevant software installation) in a local desktop configuration but you may
404
+ need to customize them if using in a CI environment where additional options may need to be passed
405
+ to the browsers. See the section on adding and configuring drivers.
412
406
 
413
- And you can use it by:
414
407
 
415
- ```ruby
416
- Capybara.javascript_driver = :webkit
417
- ```
408
+ **Note**: drivers which run the server in a different thread may not share the
409
+ same transaction as your tests, causing data not to be shared between your test
410
+ and test server, see [Transactions and database setup](#transactions-and-database-setup) below.
418
411
 
419
- ### <a name="poltergeist"></a>Poltergeist
412
+ ### <a name="apparition"></a>Apparition
420
413
 
421
- [Poltergeist](https://github.com/teampoltergeist/poltergeist) is another
422
- headless driver which integrates Capybara with
423
- [PhantomJS](http://phantomjs.org/). It is truly headless, so doesn't
424
- require Xvfb to run on your CI server. It will also detect and report
425
- any Javascript errors that happen within the page.
414
+ The [apparition driver](https://github.com/twalpole/apparition) is a new driver that allows you to run tests using Chrome in a headless
415
+ or headed configuration. It attempts to provide backwards compatibility with the [Poltergeist driver API](https://github.com/teampoltergeist/poltergeist)
416
+ and [capybara-webkit API](https://github.com/thoughtbot/capybara-webkit) while allowing for the use of modern JS/CSS. It
417
+ uses CDP to communicate with Chrome, thereby obviating the need for chromedriver. This driver is being developed by the
418
+ current developer of Capybara and will attempt to keep up to date with new Capybara releases. It will probably be moved into the
419
+ teamcapybara repo once it reaches v1.0.
426
420
 
427
421
  ## <a name="the-dsl"></a>The DSL
428
422
 
@@ -617,16 +611,26 @@ In drivers which support it, you can easily execute JavaScript:
617
611
  page.execute_script("$('body').empty()")
618
612
  ```
619
613
 
620
- For simple expressions, you can return the result of the script. Note
621
- that this may break with more complicated expressions:
614
+ For simple expressions, you can return the result of the script.
622
615
 
623
616
  ```ruby
624
617
  result = page.evaluate_script('4 + 4');
625
618
  ```
626
619
 
620
+ For more complicated scripts you'll need to write them as one expression.
621
+
622
+ ```ruby
623
+ result = page.evaluate_script(<<~JS, 3, element)
624
+ (function(n, el){
625
+ var val = parseInt(el.value, 10);
626
+ return n+val;
627
+ })(arguments[0], arguments[1])
628
+ JS
629
+ ```
630
+
627
631
  ### <a name="modals"></a>Modals
628
632
 
629
- In drivers which support it, you can accept, dismiss and respond to alerts, confirms and prompts.
633
+ In drivers which support it, you can accept, dismiss and respond to alerts, confirms, and prompts.
630
634
 
631
635
  You can accept or dismiss alert messages by wrapping the code that produces an alert in a block:
632
636
 
@@ -742,7 +746,7 @@ Capybara 1.x, set `Capybara.match` to `:prefer_exact`.
742
746
 
743
747
  ## <a name="transactions-and-database-setup"></a>Transactions and database setup
744
748
 
745
- **Note:** Rails 5.1+ now "safely" shares the database connection between the app and test threads. Therefore,
749
+ **Note:** Rails 5.1+ "safely" shares the database connection between the app and test threads. Therefore,
746
750
  if using Rails 5.1+ you SHOULD be able to ignore this section.
747
751
 
748
752
  Some Capybara drivers need to run against an actual HTTP server. Capybara takes
@@ -777,7 +781,7 @@ expect(page).to have_content('baz')
777
781
  If clicking on the *foo* link triggers an asynchronous process, such as
778
782
  an Ajax request, which, when complete will add the *bar* link to the page,
779
783
  clicking on the *bar* link would be expected to fail, since that link doesn't
780
- exist yet. However Capybara is smart enough to retry finding the link for a
784
+ exist yet. However, Capybara is smart enough to retry finding the link for a
781
785
  brief period of time before giving up and throwing an error. The same is true of
782
786
  the next line, which looks for the content *baz* on the page; it will retry
783
787
  looking for that content for a brief time. You can adjust how long this period
@@ -791,13 +795,25 @@ Be aware that because of this behaviour, the following two statements are **not*
791
795
  equivalent, and you should **always** use the latter!
792
796
 
793
797
  ```ruby
794
- !page.has_xpath?('a')
795
- page.has_no_xpath?('a')
798
+ # Given use of a driver where the page is loaded when visit returns
799
+ # and that Capybara.predicates_wait is `true`
800
+ # consider a page where the `a` tag is removed through AJAX after 1s
801
+ visit(some_path)
802
+ !page.has_xpath?('a') # is false
803
+ page.has_no_xpath?('a') # is true
796
804
  ```
797
805
 
798
- The former would immediately fail because the content has not yet been removed.
799
- Only the latter would wait for the asynchronous process to remove the content
800
- from the page.
806
+ First expression:
807
+ - `has_xpath?('a')` is called right after `visit` returns. It is `true` because the link has not yet been removed
808
+ - Capybara does not wait upon successful predicates/assertions, therefore **has_xpath? returns `true` immediately**
809
+ - The expression returns `false` (because it is negated with the leading `!`)
810
+
811
+ Second expression:
812
+ - `has_no_xpath?('a')` is called right after `visit` returns. It is `false` because the link has not yet been removed.
813
+ - Capybara waits upon failed predicates/assertions, therefore **has_no_xpath? does not return `false` immediately**
814
+ - Capybara will periodically re-check the predicate/assertion up to the `default_max_wait_time` defined
815
+ - after 1s, the predicate becomes `true` (because the link has been removed)
816
+ - The expression returns `true`
801
817
 
802
818
  Capybara's RSpec matchers, however, are smart enough to handle either form.
803
819
  The two following statements are functionally equivalent:
@@ -932,12 +948,17 @@ Capybara.default_selector = :xpath
932
948
  find('.//ul/li').text
933
949
  ```
934
950
 
935
- Capybara allows you to add custom selectors, which can be very useful if you
936
- find yourself using the same kinds of selectors very often:
951
+ Capybara provides a number of other built-in selector types. The full list, along
952
+ with applicable filters, can be seen at [built-in selectors](https://www.rubydoc.info/github/teamcapybara/capybara/Capybara/Selector)
953
+
954
+ Capybara also allows you to add custom selectors, which can be very useful if you
955
+ find yourself using the same kinds of selectors very often. The examples below are very
956
+ simple, and there are many available features not demonstrated. For more in-depth examples
957
+ please see Capybaras built-in selector definitions.
937
958
 
938
959
  ```ruby
939
- Capybara.add_selector(:id) do
940
- xpath { |id| XPath.descendant[XPath.attr(:id) == id.to_s] }
960
+ Capybara.add_selector(:my_attribute) do
961
+ xpath { |id| XPath.descendant[XPath.attr(:my_attribute) == id.to_s] }
941
962
  end
942
963
 
943
964
  Capybara.add_selector(:row) do
@@ -954,9 +975,9 @@ an XPath expression generated through the XPath gem. You can now use these
954
975
  selectors like this:
955
976
 
956
977
  ```ruby
957
- find(:id, 'post_123')
958
- find(:row, 3)
959
- find(:flash_type, :notice)
978
+ find(:my_attribute, 'post_123') # find element with matching attribute
979
+ find(:row, 3) # find 3rd row in table body
980
+ find(:flash_type, :notice) # find element with id of 'flash' and class of 'notice'
960
981
  ```
961
982
 
962
983
  ## <a name="beware-the-xpath--trap"></a>Beware the XPath // trap
@@ -1002,6 +1023,7 @@ end
1002
1023
  However, it's also possible to give this configuration a different name.
1003
1024
 
1004
1025
  ```ruby
1026
+ # Note: Capybara registers this by default
1005
1027
  Capybara.register_driver :selenium_chrome do |app|
1006
1028
  Capybara::Selenium::Driver.new(app, :browser => :chrome)
1007
1029
  end
@@ -1047,7 +1069,14 @@ additional info about how the underlying driver can be configured.
1047
1069
  are testing for specific server errors and using multiple sessions make sure to test for the
1048
1070
  errors using the initial session (usually :default)
1049
1071
 
1050
- ## <a name="threadsafe"></a>"Threadsafe" mode - BETA - may change
1072
+ * If WebMock is enabled, you may encounter a "Too many open files"
1073
+ error. A simple `page.find` call may cause thousands of HTTP requests
1074
+ until the timeout occurs. By default, WebMock will cause each of these
1075
+ requests to spawn a new connection. To work around this problem, you
1076
+ may need to [enable WebMock's `net_http_connect_on_start: true`
1077
+ parameter](https://github.com/bblimke/webmock/blob/master/README.md#connecting-on-nethttpstart).
1078
+
1079
+ ## <a name="threadsafe"></a>"Threadsafe" mode
1051
1080
 
1052
1081
  In normal mode most of Capybara's configuration options are global settings which can cause issues
1053
1082
  if using multiple sessions and wanting to change a setting for only one of the sessions. To provide
@@ -1082,7 +1111,8 @@ To set up a development environment, simply do:
1082
1111
 
1083
1112
  ```bash
1084
1113
  bundle install
1085
- bundle exec rake # run the test suite
1114
+ bundle exec rake # run the test suite with Firefox - requires `geckodriver` to be installed
1115
+ bundle exec rake spec_chrome # run the test suite with Chrome - require `chromedriver` to be installed
1086
1116
  ```
1087
1117
 
1088
1118
  See
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'forwardable'
3
4
  require 'capybara/session/config'
4
5
 
@@ -6,11 +7,12 @@ module Capybara
6
7
  class Config
7
8
  extend Forwardable
8
9
 
9
- OPTIONS = [:app, :reuse_server, :threadsafe, :default_wait_time, :server, :default_driver, :javascript_driver]
10
+ OPTIONS = %i[
11
+ app reuse_server threadsafe server default_driver javascript_driver use_html5_parsing allow_gumbo
12
+ ].freeze
10
13
 
11
- attr_accessor :app
12
- attr_reader :reuse_server, :threadsafe
13
- attr_reader :session_options
14
+ attr_accessor :app, :use_html5_parsing
15
+ attr_reader :reuse_server, :threadsafe, :session_options # rubocop:disable Style/BisectedAttrAccessor
14
16
  attr_writer :default_driver, :javascript_driver
15
17
 
16
18
  SessionConfig::OPTIONS.each do |method|
@@ -19,15 +21,16 @@ module Capybara
19
21
 
20
22
  def initialize
21
23
  @session_options = Capybara::SessionConfig.new
24
+ @javascript_driver = nil
22
25
  end
23
26
 
24
- def reuse_server=(bool)
25
- @reuse_server = bool
26
- end
27
+ attr_writer :reuse_server # rubocop:disable Style/BisectedAttrAccessor
27
28
 
28
29
  def threadsafe=(bool)
29
- warn "Capybara.threadsafe == true is a BETA feature and may change in future minor versions" if bool
30
- raise "Threadsafe setting cannot be changed once a session is created" if (bool != threadsafe) && Session.instance_created?
30
+ if (bool != threadsafe) && Session.instance_created?
31
+ raise 'Threadsafe setting cannot be changed once a session is created'
32
+ end
33
+
31
34
  @threadsafe = bool
32
35
  end
33
36
 
@@ -35,16 +38,9 @@ module Capybara
35
38
  #
36
39
  # Return the proc that Capybara will call to run the Rack application.
37
40
  # The block returned receives a rack app, port, and host/ip and should run a Rack handler
38
- # By default, Capybara will try to run webrick.
41
+ # By default, Capybara will try to use puma.
39
42
  #
40
- def server(&block)
41
- if block_given?
42
- warn "DEPRECATED: Passing a block to Capybara::server is deprecated, please use Capybara::register_server instead"
43
- @server = block
44
- else
45
- @server
46
- end
47
- end
43
+ attr_reader :server
48
44
 
49
45
  ##
50
46
  #
@@ -64,12 +60,10 @@ module Capybara
64
60
  name, options = *name if name.is_a? Array
65
61
  @server = if name.respond_to? :call
66
62
  name
63
+ elsif options
64
+ proc { |app, port, host| Capybara.servers[name.to_sym].call(app, port, host, **options) }
67
65
  else
68
- if options
69
- Proc.new { |app, port, host| Capybara.servers[name.to_sym].call(app,port,host,options) }
70
- else
71
- Capybara.servers[name.to_sym]
72
- end
66
+ Capybara.servers[name.to_sym]
73
67
  end
74
68
  end
75
69
 
@@ -89,44 +83,22 @@ module Capybara
89
83
  @javascript_driver || :selenium
90
84
  end
91
85
 
92
- # @deprecated Use default_max_wait_time instead
93
- def default_wait_time
94
- deprecate('default_wait_time', 'default_max_wait_time', true)
95
- default_max_wait_time
96
- end
97
-
98
- # @deprecated Use default_max_wait_time= instead
99
- def default_wait_time=(t)
100
- deprecate('default_wait_time=', 'default_max_wait_time=')
101
- self.default_max_wait_time = t
102
- end
103
-
104
- def deprecate(method, alternate_method, once=false)
86
+ def deprecate(method, alternate_method, once: false)
105
87
  @deprecation_notified ||= {}
106
- warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead" unless once and @deprecation_notified[method]
107
- @deprecation_notified[method]=true
108
- end
109
- end
110
-
111
- # @api private
112
- class ConfigureDeprecator
113
- def initialize(config)
114
- @config = config
88
+ unless once && @deprecation_notified[method]
89
+ Capybara::Helpers.warn "DEPRECATED: ##{method} is deprecated, please use ##{alternate_method} instead: #{Capybara::Helpers.filter_backtrace(caller)}"
90
+ end
91
+ @deprecation_notified[method] = true
115
92
  end
116
93
 
117
- def method_missing(m, *args, &block)
118
- if @config.respond_to?(m)
119
- @config.public_send(m, *args, &block)
120
- elsif Capybara.respond_to?(m)
121
- warn "Calling #{m} from Capybara.configure is deprecated - please call it on Capybara directly ( Capybara.#{m}(...) )"
122
- Capybara.public_send(m, *args, &block)
123
- else
124
- super
125
- end
94
+ def allow_gumbo=(val)
95
+ deprecate('allow_gumbo=', 'use_html5_parsing=')
96
+ self.use_html5_parsing = val
126
97
  end
127
98
 
128
- def respond_to_missing?(m, include_private = false)
129
- @config.respond_to?(m) || Capybara.respond_to?(m) || super
99
+ def allow_gumbo
100
+ deprecate('allow_gumbo', 'use_html5_parsing')
101
+ use_html5_parsing
130
102
  end
131
103
  end
132
- end
104
+ end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'capybara/dsl'
3
4
  require 'capybara/rspec/matchers'
4
5
  require 'capybara/rspec/matcher_proxies'
@@ -21,8 +22,6 @@ end
21
22
  Before do |scenario|
22
23
  scenario.source_tag_names.each do |tag|
23
24
  driver_name = tag.sub(/^@/, '').to_sym
24
- if Capybara.drivers.has_key?(driver_name)
25
- Capybara.current_driver = driver_name
26
- end
25
+ Capybara.current_driver = driver_name if Capybara.drivers[driver_name]
27
26
  end
28
27
  end