capybara 2.15.1 → 3.36.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (311) hide show
  1. checksums.yaml +5 -5
  2. data/.yardopts +1 -1
  3. data/History.md +902 -10
  4. data/License.txt +1 -1
  5. data/README.md +103 -75
  6. data/lib/capybara/config.rb +29 -56
  7. data/lib/capybara/cucumber.rb +2 -3
  8. data/lib/capybara/driver/base.rb +39 -18
  9. data/lib/capybara/driver/node.rb +36 -10
  10. data/lib/capybara/dsl.rb +15 -6
  11. data/lib/capybara/helpers.rb +65 -30
  12. data/lib/capybara/minitest/spec.rb +173 -81
  13. data/lib/capybara/minitest.rb +220 -111
  14. data/lib/capybara/node/actions.rb +274 -171
  15. data/lib/capybara/node/base.rb +41 -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 +353 -137
  19. data/lib/capybara/node/finders.rb +144 -138
  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 +13 -10
  24. data/lib/capybara/queries/base_query.rb +39 -28
  25. data/lib/capybara/queries/current_path_query.rb +22 -25
  26. data/lib/capybara/queries/match_query.rb +14 -7
  27. data/lib/capybara/queries/selector_query.rb +646 -145
  28. data/lib/capybara/queries/sibling_query.rb +12 -10
  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 +57 -41
  33. data/lib/capybara/rack_test/css_handlers.rb +6 -4
  34. data/lib/capybara/rack_test/driver.rb +18 -13
  35. data/lib/capybara/rack_test/errors.rb +6 -0
  36. data/lib/capybara/rack_test/form.rb +73 -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 +44 -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 +45 -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 +144 -264
  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 +279 -0
  86. data/lib/capybara/selector/filter.rb +2 -17
  87. data/lib/capybara/selector/filter_set.rb +81 -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 +214 -0
  93. data/lib/capybara/selector/selector.rb +89 -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 +343 -276
  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 +228 -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 +40 -0
  112. data/lib/capybara/selenium/node.rb +508 -124
  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 +69 -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 +79 -59
  129. data/lib/capybara/session/matchers.rb +41 -25
  130. data/lib/capybara/session.rb +371 -357
  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 +159 -13
  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 +34 -6
  137. data/lib/capybara/spec/session/active_element_spec.rb +31 -0
  138. data/lib/capybara/spec/session/all_spec.rb +161 -55
  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.rb → assert_text_spec.rb} +91 -59
  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 +138 -69
  147. data/lib/capybara/spec/session/body_spec.rb +12 -13
  148. data/lib/capybara/spec/session/check_spec.rb +116 -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 +11 -10
  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 +23 -0
  162. data/lib/capybara/spec/session/evaluate_script_spec.rb +30 -9
  163. data/lib/capybara/spec/session/execute_script_spec.rb +10 -8
  164. data/lib/capybara/spec/session/fill_in_spec.rb +128 -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 +245 -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 +69 -0
  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 +94 -13
  181. data/lib/capybara/spec/session/has_css_spec.rb +272 -137
  182. data/lib/capybara/spec/session/has_current_path_spec.rb +87 -45
  183. data/lib/capybara/spec/session/has_field_spec.rb +139 -59
  184. data/lib/capybara/spec/session/has_link_spec.rb +34 -9
  185. data/lib/capybara/spec/session/has_none_selectors_spec.rb +78 -0
  186. data/lib/capybara/spec/session/has_select_spec.rb +103 -74
  187. data/lib/capybara/spec/session/has_selector_spec.rb +105 -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 +113 -61
  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 +950 -152
  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 +69 -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 -80
  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 +99 -32
  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 +70 -44
  224. data/lib/capybara/spec/spec_helper.rb +49 -43
  225. data/lib/capybara/spec/test_app.rb +89 -42
  226. data/lib/capybara/spec/views/animated.erb +49 -0
  227. data/lib/capybara/spec/views/form.erb +141 -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 +11 -0
  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 +18 -0
  247. data/lib/capybara/spec/views/with_hover.erb +8 -2
  248. data/lib/capybara/spec/views/with_hover1.erb +10 -0
  249. data/lib/capybara/spec/views/with_html.erb +70 -11
  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 +39 -3
  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_other.erb +6 -0
  256. data/lib/capybara/spec/views/with_slow_unload.erb +2 -1
  257. data/lib/capybara/spec/views/with_sortable_js.erb +21 -0
  258. data/lib/capybara/spec/views/with_unload_alert.erb +1 -0
  259. data/lib/capybara/spec/views/with_windows.erb +1 -1
  260. data/lib/capybara/spec/views/within_frames.erb +5 -2
  261. data/lib/capybara/version.rb +2 -1
  262. data/lib/capybara/window.rb +35 -33
  263. data/lib/capybara.rb +126 -103
  264. data/spec/basic_node_spec.rb +60 -34
  265. data/spec/capybara_spec.rb +53 -104
  266. data/spec/css_builder_spec.rb +101 -0
  267. data/spec/css_splitter_spec.rb +38 -0
  268. data/spec/dsl_spec.rb +81 -62
  269. data/spec/filter_set_spec.rb +27 -9
  270. data/spec/fixtures/certificate.pem +25 -0
  271. data/spec/fixtures/key.pem +27 -0
  272. data/spec/fixtures/selenium_driver_rspec_failure.rb +5 -4
  273. data/spec/fixtures/selenium_driver_rspec_success.rb +5 -4
  274. data/spec/minitest_spec.rb +49 -7
  275. data/spec/minitest_spec_spec.rb +94 -59
  276. data/spec/per_session_config_spec.rb +14 -13
  277. data/spec/rack_test_spec.rb +180 -125
  278. data/spec/regexp_dissassembler_spec.rb +250 -0
  279. data/spec/result_spec.rb +99 -45
  280. data/spec/rspec/features_spec.rb +37 -31
  281. data/spec/rspec/scenarios_spec.rb +9 -7
  282. data/spec/rspec/shared_spec_matchers.rb +448 -421
  283. data/spec/rspec/views_spec.rb +5 -3
  284. data/spec/rspec_matchers_spec.rb +27 -11
  285. data/spec/rspec_spec.rb +109 -89
  286. data/spec/sauce_spec_chrome.rb +43 -0
  287. data/spec/selector_spec.rb +396 -67
  288. data/spec/selenium_spec_chrome.rb +183 -35
  289. data/spec/selenium_spec_chrome_remote.rb +101 -0
  290. data/spec/selenium_spec_edge.rb +47 -0
  291. data/spec/selenium_spec_firefox.rb +184 -41
  292. data/spec/selenium_spec_firefox_remote.rb +80 -0
  293. data/spec/selenium_spec_ie.rb +147 -0
  294. data/spec/selenium_spec_safari.rb +156 -0
  295. data/spec/server_spec.rb +198 -99
  296. data/spec/session_spec.rb +53 -16
  297. data/spec/shared_selenium_node.rb +79 -0
  298. data/spec/shared_selenium_session.rb +489 -97
  299. data/spec/spec_helper.rb +93 -7
  300. data/spec/xpath_builder_spec.rb +93 -0
  301. metadata +365 -70
  302. data/.yard/templates_custom/default/class/html/selectors.erb +0 -38
  303. data/.yard/templates_custom/default/class/html/setup.rb +0 -17
  304. data/.yard/yard_extensions.rb +0 -78
  305. data/lib/capybara/query.rb +0 -7
  306. data/lib/capybara/rspec/compound.rb +0 -95
  307. data/lib/capybara/spec/session/assert_current_path.rb +0 -72
  308. data/lib/capybara/spec/session/assert_selector.rb +0 -148
  309. data/lib/capybara/spec/session/source_spec.rb +0 -0
  310. data/lib/capybara/spec/views/with_title.erb +0 -5
  311. data/spec/selenium_spec_marionette.rb +0 -117
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,15 +1,23 @@
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
10
12
  comes with Rack::Test and Selenium support built in. WebKit is supported
11
13
  through an external gem.
12
14
 
15
+ ## Support Capybara
16
+
17
+ If you and/or your company find value in Capybara and would like to contribute financially to its ongoing maintenance and development, please visit
18
+ <a href="https://www.patreon.com/capybara">Patreon</a>
19
+
20
+
13
21
  **Need help?** Ask on the mailing list (please do not open an issue on
14
22
  GitHub): http://groups.google.com/group/ruby-capybara
15
23
 
@@ -26,8 +34,7 @@ GitHub): http://groups.google.com/group/ruby-capybara
26
34
  - [Selecting the Driver](#selecting-the-driver)
27
35
  - [RackTest](#racktest)
28
36
  - [Selenium](#selenium)
29
- - [Capybara-webkit](#capybara-webkit)
30
- - [Poltergeist](#poltergeist)
37
+ - [Apparition](#apparition)
31
38
  - [The DSL](#the-dsl)
32
39
  - [Navigating](#navigating)
33
40
  - [Clicking links and buttons](#clicking-links-and-buttons)
@@ -47,11 +54,13 @@ GitHub): http://groups.google.com/group/ruby-capybara
47
54
  - [Using the DSL elsewhere](#using-the-dsl-elsewhere)
48
55
  - [Calling remote servers](#calling-remote-servers)
49
56
  - [Using sessions](#using-sessions)
57
+ - [Named sessions](#named-sessions)
58
+ - [Using sessions manually](#using-sessions-manually)
50
59
  - [XPath, CSS and selectors](#xpath-css-and-selectors)
51
60
  - [Beware the XPath // trap](#beware-the-xpath--trap)
52
61
  - [Configuring and adding drivers](#configuring-and-adding-drivers)
53
62
  - [Gotchas:](#gotchas)
54
- - ["Threadsafe" mode](#threadsafe)
63
+ - ["Threadsafe" mode](#threadsafe-mode)
55
64
  - [Development](#development)
56
65
 
57
66
  ## <a name="key-benefits"></a>Key benefits
@@ -65,24 +74,19 @@ GitHub): http://groups.google.com/group/ruby-capybara
65
74
 
66
75
  ## <a name="setup"></a>Setup
67
76
 
68
- Capybara requires Ruby 1.9.3 or later. To install, add this line to your
77
+ Capybara requires Ruby 2.6.0 or later. To install, add this line to your
69
78
  `Gemfile` and run `bundle install`:
70
79
 
71
80
  ```ruby
72
81
  gem 'capybara'
73
82
  ```
74
83
 
75
- **Note:** If using Ruby < 2.0 you will also need to limit the version of rack to < 2.0
76
-
77
84
  If the application that you are testing is a Rails app, add this line to your test helper file:
78
85
 
79
86
  ```ruby
80
87
  require 'capybara/rails'
81
88
  ```
82
89
 
83
- **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).
84
- If you experience random errors about missing constants, add `config.allow_concurrency = false` to `config/environments/test.rb`.
85
-
86
90
  If the application that you are testing is a Rack app, but not Rails, set Capybara.app to your Rack app:
87
91
 
88
92
  ```ruby
@@ -134,26 +138,28 @@ There are also explicit tags for each registered driver set up for you (`@seleni
134
138
 
135
139
  ## <a name="using-capybara-with-rspec"></a>Using Capybara with RSpec
136
140
 
137
- 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
138
142
  `spec_helper.rb` file):
139
143
 
140
144
  ```ruby
141
145
  require 'capybara/rspec'
142
146
  ```
143
147
 
144
- 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
145
149
  if [you have it configured in
146
- 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))
147
151
  and if you have your Capybara specs in a different directory, then tag the
148
- 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.
149
155
 
150
156
  If you are not using Rails, tag all the example groups in which you want to use
151
- Capybara with `:type => :feature`.
157
+ Capybara with `type: :feature`.
152
158
 
153
159
  You can now write your specs like so:
154
160
 
155
161
  ```ruby
156
- describe "the signin process", :type => :feature do
162
+ describe "the signin process", type: :feature do
157
163
  before :each do
158
164
  User.make(email: 'user@example.com', password: 'password')
159
165
  end
@@ -177,7 +183,7 @@ to one specific driver. For example:
177
183
  ```ruby
178
184
  describe 'some stuff which requires js', js: true do
179
185
  it 'will use the default js driver'
180
- it 'will switch to one specific driver', :driver => :webkit
186
+ it 'will switch to one specific driver', driver: :apparition
181
187
  end
182
188
  ```
183
189
 
@@ -213,11 +219,11 @@ feature "Signing in" do
213
219
  end
214
220
  ```
215
221
 
216
- `feature` is in fact just an alias for `describe ..., :type => :feature`,
222
+ `feature` is in fact just an alias for `describe ..., type: :feature`,
217
223
  `background` is an alias for `before`, `scenario` for `it`, and
218
224
  `given`/`given!` aliases for `let`/`let!`, respectively.
219
225
 
220
- Finally, Capybara matchers are supported in view specs:
226
+ Finally, Capybara matchers are also supported in view specs:
221
227
 
222
228
  ```ruby
223
229
  RSpec.describe "todos/show.html.erb", type: :view do
@@ -254,7 +260,9 @@ end
254
260
 
255
261
  ## <a name="using-capybara-with-minitest"></a>Using Capybara with Minitest
256
262
 
257
- * 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`
258
266
  file to make Capybara available in all test cases deriving from
259
267
  `ActionDispatch::IntegrationTest`:
260
268
 
@@ -269,8 +277,7 @@ end
269
277
  include Capybara::Minitest::Assertions
270
278
 
271
279
  # Reset sessions and driver between tests
272
- # Use super wherever this method is redefined in your individual test classes
273
- def teardown
280
+ teardown do
274
281
  Capybara.reset_sessions!
275
282
  Capybara.use_default_driver
276
283
  end
@@ -335,9 +342,9 @@ For example if you'd prefer to run everything in Selenium, you could do:
335
342
  Capybara.default_driver = :selenium # :selenium_chrome and :selenium_chrome_headless are also registered
336
343
  ```
337
344
 
338
- However, if you are using RSpec or Cucumber, you may instead want to consider
339
- leaving the faster `:rack_test` as the __default_driver__, and marking only those
340
- 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
341
348
  `@javascript`, respectively. By default, JavaScript tests are run using the
342
349
  `:selenium` driver. You can change this by setting
343
350
  `Capybara.javascript_driver`.
@@ -346,7 +353,7 @@ You can also change the driver temporarily (typically in the Before/setup and
346
353
  After/teardown blocks):
347
354
 
348
355
  ```ruby
349
- Capybara.current_driver = :webkit # temporarily select different driver
356
+ Capybara.current_driver = :apparition # temporarily select different driver
350
357
  # tests here
351
358
  Capybara.use_default_driver # switch back to default driver
352
359
  ```
@@ -381,42 +388,35 @@ See the section on adding and configuring drivers.
381
388
 
382
389
  ### <a name="selenium"></a>Selenium
383
390
 
384
- At the moment, Capybara supports [Selenium 2.0+
385
- (Webdriver)](http://seleniumhq.org/docs/01_introducing_selenium.html#selenium-2-aka-selenium-webdriver),
386
- *not* Selenium RC. In order to use Selenium, you'll need to install the
387
- `selenium-webdriver` gem, and add it to your Gemfile if you're using bundler.
388
- Provided Firefox is installed, everything is set up for you, and you should be
389
- 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.
390
395
 
391
- **Note**: drivers which run the server in a different thread may not share the
392
- same transaction as your tests, causing data not to be shared between your test
393
- and test server, see "Transactions and database setup" below.
396
+ Capybara pre-registers a number of named drivers that use Selenium - they are:
394
397
 
395
- ### <a name="capybara-webkit"></a>Capybara-webkit
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
396
402
 
397
- The [capybara-webkit driver](https://github.com/thoughtbot/capybara-webkit) is for true headless
398
- testing. It uses QtWebKit to start a rendering engine process. It can execute JavaScript as well.
399
- It is significantly faster than drivers like Selenium since it does not load an entire browser.
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.
400
406
 
401
- You can install it with:
402
407
 
403
- ```bash
404
- gem install capybara-webkit
405
- ```
406
-
407
- And you can use it by:
408
-
409
- ```ruby
410
- Capybara.javascript_driver = :webkit
411
- ```
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.
412
411
 
413
- ### <a name="poltergeist"></a>Poltergeist
412
+ ### <a name="apparition"></a>Apparition
414
413
 
415
- [Poltergeist](https://github.com/teampoltergeist/poltergeist) is another
416
- headless driver which integrates Capybara with
417
- [PhantomJS](http://phantomjs.org/). It is truly headless, so doesn't
418
- require Xvfb to run on your CI server. It will also detect and report
419
- 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.
420
420
 
421
421
  ## <a name="the-dsl"></a>The DSL
422
422
 
@@ -543,7 +543,7 @@ If you find yourself needing to use this a lot you may be better off adding a [c
543
543
  ```ruby
544
544
  find_field('First Name'){ |el| el['data-xyz'] == '123' }
545
545
  find("#img_loading"){ |img| img['complete'] == true }
546
- ````
546
+ ```
547
547
 
548
548
  **Note**: `find` will wait for an element to appear on the page, as explained in the
549
549
  Ajax section. If the element does not appear it will raise an error.
@@ -611,13 +611,23 @@ In drivers which support it, you can easily execute JavaScript:
611
611
  page.execute_script("$('body').empty()")
612
612
  ```
613
613
 
614
- For simple expressions, you can return the result of the script. Note
615
- that this may break with more complicated expressions:
614
+ For simple expressions, you can return the result of the script.
616
615
 
617
616
  ```ruby
618
617
  result = page.evaluate_script('4 + 4');
619
618
  ```
620
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
+
621
631
  ### <a name="modals"></a>Modals
622
632
 
623
633
  In drivers which support it, you can accept, dismiss and respond to alerts, confirms and prompts.
@@ -736,7 +746,7 @@ Capybara 1.x, set `Capybara.match` to `:prefer_exact`.
736
746
 
737
747
  ## <a name="transactions-and-database-setup"></a>Transactions and database setup
738
748
 
739
- **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,
740
750
  if using Rails 5.1+ you SHOULD be able to ignore this section.
741
751
 
742
752
  Some Capybara drivers need to run against an actual HTTP server. Capybara takes
@@ -888,7 +898,7 @@ To permanently switch the current session to a different session
888
898
 
889
899
  ```ruby
890
900
  Capybara.session_name = "some other session"
891
- ````
901
+ ```
892
902
 
893
903
  ### <a name="using-sessions-manually"></a>Using sessions manually
894
904
 
@@ -926,12 +936,17 @@ Capybara.default_selector = :xpath
926
936
  find('.//ul/li').text
927
937
  ```
928
938
 
929
- Capybara allows you to add custom selectors, which can be very useful if you
930
- find yourself using the same kinds of selectors very often:
939
+ Capybara provides a number of other built-in selector types. The full list, along
940
+ with applicable filters, can be seen at [built-in selectors](https://www.rubydoc.info/github/teamcapybara/capybara/Capybara/Selector)
941
+
942
+ Capybara also allows you to add custom selectors, which can be very useful if you
943
+ find yourself using the same kinds of selectors very often. The examples below are very
944
+ simple, and there are many available features not demonstrated. For more in-depth examples
945
+ please see Capybaras built-in selector definitions.
931
946
 
932
947
  ```ruby
933
- Capybara.add_selector(:id) do
934
- xpath { |id| XPath.descendant[XPath.attr(:id) == id.to_s] }
948
+ Capybara.add_selector(:my_attribute) do
949
+ xpath { |id| XPath.descendant[XPath.attr(:my_attribute) == id.to_s] }
935
950
  end
936
951
 
937
952
  Capybara.add_selector(:row) do
@@ -948,9 +963,9 @@ an XPath expression generated through the XPath gem. You can now use these
948
963
  selectors like this:
949
964
 
950
965
  ```ruby
951
- find(:id, 'post_123')
952
- find(:row, 3)
953
- find(:flash_type, :notice)
966
+ find(:my_attribute, 'post_123') # find element with matching attribute
967
+ find(:row, 3) # find 3rd row in table body
968
+ find(:flash_type, :notice) # find element with id of 'flash' and class of 'notice'
954
969
  ```
955
970
 
956
971
  ## <a name="beware-the-xpath--trap"></a>Beware the XPath // trap
@@ -996,6 +1011,7 @@ end
996
1011
  However, it's also possible to give this configuration a different name.
997
1012
 
998
1013
  ```ruby
1014
+ # Note: Capybara registers this by default
999
1015
  Capybara.register_driver :selenium_chrome do |app|
1000
1016
  Capybara::Selenium::Driver.new(app, :browser => :chrome)
1001
1017
  end
@@ -1041,13 +1057,22 @@ additional info about how the underlying driver can be configured.
1041
1057
  are testing for specific server errors and using multiple sessions make sure to test for the
1042
1058
  errors using the initial session (usually :default)
1043
1059
 
1044
- ## <a name="threadsafe"></a>"Threadsafe" mode - BETA - may change
1060
+ * If WebMock is enabled, you may encounter a "Too many open files"
1061
+ error. A simple `page.find` call may cause thousands of HTTP requests
1062
+ until the timeout occurs. By default, WebMock will cause each of these
1063
+ requests to spawn a new connection. To work around this problem, you
1064
+ may need to [enable WebMock's `net_http_connect_on_start: true`
1065
+ parameter](https://github.com/bblimke/webmock/blob/master/README.md#connecting-on-nethttpstart).
1066
+
1067
+ ## <a name="threadsafe"></a>"Threadsafe" mode
1045
1068
 
1046
1069
  In normal mode most of Capybara's configuration options are global settings which can cause issues
1047
1070
  if using multiple sessions and wanting to change a setting for only one of the sessions. To provide
1048
1071
  support for this type of usage Capybara now provides a "threadsafe" mode which can be enabled by setting
1049
1072
 
1050
- Capybara.threadsafe = true
1073
+ ```ruby
1074
+ Capybara.threadsafe = true
1075
+ ```
1051
1076
 
1052
1077
  This setting can only be changed before any sessions have been created. In "threadsafe" mode the following
1053
1078
  behaviors of Capybara change
@@ -1057,11 +1082,13 @@ behaviors of Capybara change
1057
1082
  `app`, `reuse_server`, `default_driver`, `javascript_driver`, and (obviously) `threadsafe`. Any drivers and servers
1058
1083
  registered through `register_driver` and `register_server` are also global.
1059
1084
 
1060
- my_session = Capybara::Session.new(:driver, some_app) do |config|
1061
- config.automatic_label_click = true # only set for my_session
1062
- end
1063
- my_session.config.default_max_wait_time = 10 # only set for my_session
1064
- Capybara.default_max_wait_time = 2 # will not change the default_max_wait in my_session
1085
+ ```ruby
1086
+ my_session = Capybara::Session.new(:driver, some_app) do |config|
1087
+ config.automatic_label_click = true # only set for my_session
1088
+ end
1089
+ my_session.config.default_max_wait_time = 10 # only set for my_session
1090
+ Capybara.default_max_wait_time = 2 # will not change the default_max_wait in my_session
1091
+ ```
1065
1092
 
1066
1093
  * `current_driver` and `session_name` are thread specific. This means that `using_session` and
1067
1094
  `using_driver` also only affect the current thread.
@@ -1072,7 +1099,8 @@ To set up a development environment, simply do:
1072
1099
 
1073
1100
  ```bash
1074
1101
  bundle install
1075
- bundle exec rake # run the test suite
1102
+ bundle exec rake # run the test suite with Firefox - requires `geckodriver` to be installed
1103
+ bundle exec rake spec_chrome # run the test suite with Chrome - require `chromedriver` to be installed
1076
1104
  ```
1077
1105
 
1078
1106
  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,43 +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
- class ConfigureDeprecator
112
- def initialize(config)
113
- @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
114
92
  end
115
93
 
116
- def method_missing(m, *args, &block)
117
- if @config.respond_to?(m)
118
- @config.public_send(m, *args, &block)
119
- elsif Capybara.respond_to?(m)
120
- warn "Calling #{m} from Capybara.configure is deprecated - please call it on Capybara directly ( Capybara.#{m}(...) )"
121
- Capybara.public_send(m, *args, &block)
122
- else
123
- super
124
- end
94
+ def allow_gumbo=(val)
95
+ deprecate('allow_gumbo=', 'use_html5_parsing=')
96
+ self.use_html5_parsing = val
125
97
  end
126
98
 
127
- def respond_to_missing?(m, include_private = false)
128
- @config.respond_to_missing?(m, include_private) || Capybara.respond_to_missing?(m, include_private)
99
+ def allow_gumbo
100
+ deprecate('allow_gumbo', 'use_html5_parsing')
101
+ use_html5_parsing
129
102
  end
130
103
  end
131
- 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