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/lib/capybara.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'timeout'
3
4
  require 'nokogiri'
4
5
  require 'xpath'
5
6
  require 'forwardable'
6
7
  require 'capybara/config'
8
+ require 'capybara/registration_container'
7
9
 
8
10
  module Capybara
9
11
  class CapybaraError < StandardError; end
@@ -21,7 +23,6 @@ module Capybara
21
23
  class WindowError < CapybaraError; end
22
24
  class ReadOnlyElementError < CapybaraError; end
23
25
 
24
-
25
26
  class << self
26
27
  extend Forwardable
27
28
 
@@ -38,6 +39,8 @@ module Capybara
38
39
  # See {Capybara.configure}
39
40
  # @!method javascript_driver
40
41
  # See {Capybara.configure}
42
+ # @!method use_html5_parsing
43
+ # See {Capybara.configure}
41
44
  Config::OPTIONS.each do |method|
42
45
  def_delegators :config, method, "#{method}="
43
46
  end
@@ -51,8 +54,6 @@ module Capybara
51
54
  # See {Capybara.configure}
52
55
  # @!method always_include_port
53
56
  # See {Capybara.configure}
54
- # @!method wait_on_first_by_default
55
- # See {Capybara.configure}
56
57
  SessionConfig::OPTIONS.each do |method|
57
58
  def_delegators :config, method, "#{method}="
58
59
  end
@@ -66,35 +67,50 @@ module Capybara
66
67
  # config.app_host = 'http://www.google.com'
67
68
  # end
68
69
  #
69
- # === Configurable options
70
- #
71
- # [app_host = String/nil] The default host to use when giving a relative URL to visit, must be a valid URL e.g. http://www.example.com
72
- # [always_include_port = Boolean] Whether the Rack server's port should automatically be inserted into every visited URL (Default: false)
73
- # [asset_host = String] Where dynamic assets are hosted - will be prepended to relative asset locations if present (Default: nil)
74
- # [run_server = Boolean] Whether to start a Rack server for the given Rack app (Default: true)
75
- # [raise_server_errors = Boolean] Should errors raised in the server be raised in the tests? (Default: true)
76
- # [server_errors = Array\<Class\>] Error classes that should be raised in the tests if they are raised in the server and Capybara.raise_server_errors is true (Default: [StandardError])
77
- # [default_selector = :css/:xpath] Methods which take a selector use the given type by default (Default: :css)
78
- # [default_max_wait_time = Numeric] The maximum number of seconds to wait for asynchronous processes to finish (Default: 2)
79
- # [ignore_hidden_elements = Boolean] Whether to ignore hidden elements on the page (Default: true)
80
- # [automatic_reload = Boolean] Whether to automatically reload elements as Capybara is waiting (Default: true)
81
- # [save_path = String] Where to put pages saved through save_(page|screenshot), save_and_open_(page|screenshot) (Default: Dir.pwd)
82
- # [wait_on_first_by_default = Boolean] Whether Node#first defaults to Capybara waiting behavior for at least 1 element to match (Default: false)
83
- # [automatic_label_click = Boolean] Whether Node#choose, Node#check, Node#uncheck will attempt to click the associated label element if the checkbox/radio button are non-visible (Default: false)
84
- # [enable_aria_label = Boolean] Whether fields, links, and buttons will match against aria-label attribute (Default: false)
85
- # [reuse_server = Boolean] Reuse the server thread between multiple sessions using the same app object (Default: true)
86
- # [threadsafe = Boolean] Whether sessions can be configured individually (Default: false)
87
- # [server = Symbol] The name of the registered server to use when running the app under test (Default: :webrick)
88
- #
89
- # === DSL Options
90
- #
91
- # when using capybara/dsl, the following options are also available:
92
- #
93
- # [default_driver = Symbol] The name of the driver to use by default. (Default: :rack_test)
94
- # [javascript_driver = Symbol] The name of a driver to use for JavaScript enabled tests. (Default: :selenium)
70
+ # #### Configurable options
71
+ #
72
+ # - **use_html5_parsing** (Boolean = `false`) - When Nokogiri >= 1.12.0 or `nokogumbo` is installed, whether HTML5 parsing will be used for HTML strings.
73
+ # - **always_include_port** (Boolean = `false`) - Whether the Rack server's port should automatically be inserted into every visited URL
74
+ # unless another port is explicitly specified.
75
+ # - **app_host** (String, `nil`) - The default host to use when giving a relative URL to visit, must be a valid URL e.g. `http://www.example.com`.
76
+ # - **asset_host** (String = `nil`) - Where dynamic assets are hosted - will be prepended to relative asset locations if present.
77
+ # - **automatic_label_click** (Boolean = `false`) - Whether {Capybara::Node::Element#choose Element#choose}, {Capybara::Node::Element#check Element#check},
78
+ # {Capybara::Node::Element#uncheck Element#uncheck} will attempt to click the associated `<label>` element if the checkbox/radio button are non-visible.
79
+ # - **automatic_reload** (Boolean = `true`) - Whether to automatically reload elements as Capybara is waiting.
80
+ # - **default_max_wait_time** (Numeric = `2`) - The maximum number of seconds to wait for asynchronous processes to finish.
81
+ # - **default_normalize_ws** (Boolean = `false`) - Whether text predicates and matchers use normalize whitespace behavior.
82
+ # - **default_selector** (`:css`, `:xpath` = `:css`) - Methods which take a selector use the given type by default. See also {Capybara::Selector}.
83
+ # - **default_set_options** (Hash = `{}`) - The default options passed to {Capybara::Node::Element#set Element#set}.
84
+ # - **enable_aria_label** (Boolean = `false`) - Whether fields, links, and buttons will match against `aria-label` attribute.
85
+ # - **enable_aria_role** (Boolean = `false`) - Selectors will check for relevant aria role (currently only `button`).
86
+ # - **exact** (Boolean = `false`) - Whether locators are matched exactly or with substrings. Only affects selector conditions
87
+ # written using the `XPath#is` method.
88
+ # - **exact_text** (Boolean = `false`) - Whether the text matchers and `:text` filter match exactly or on substrings.
89
+ # - **ignore_hidden_elements** (Boolean = `true`) - Whether to ignore hidden elements on the page.
90
+ # - **match** (`:one`, `:first`, `:prefer_exact`, `:smart` = `:smart`) - The matching strategy to find nodes.
91
+ # - **predicates_wait** (Boolean = `true`) - Whether Capybara's predicate matchers use waiting behavior by default.
92
+ # - **raise_server_errors** (Boolean = `true`) - Should errors raised in the server be raised in the tests?
93
+ # - **reuse_server** (Boolean = `true`) - Whether to reuse the server thread between multiple sessions using the same app object.
94
+ # - **run_server** (Boolean = `true`) - Whether to start a Rack server for the given Rack app.
95
+ # - **save_path** (String = `Dir.pwd`) - Where to put pages saved through {Capybara::Session#save_page save_page}, {Capybara::Session#save_screenshot save_screenshot},
96
+ # {Capybara::Session#save_and_open_page save_and_open_page}, or {Capybara::Session#save_and_open_screenshot save_and_open_screenshot}.
97
+ # - **server** (Symbol = `:default` (which uses puma)) - The name of the registered server to use when running the app under test.
98
+ # - **server_port** (Integer) - The port Capybara will run the application server on, if not specified a random port will be used.
99
+ # - **server_errors** (Array\<Class> = `[Exception]`) - Error classes that should be raised in the tests if they are raised in the server
100
+ # and {configure raise_server_errors} is `true`.
101
+ # - **test_id** (Symbol, String, `nil` = `nil`) - Optional attribute to match locator against with built-in selectors along with id.
102
+ # - **threadsafe** (Boolean = `false`) - Whether sessions can be configured individually.
103
+ # - **w3c_click_offset** (Boolean = 'false') - Whether click offsets should be from element center (true) or top left (false)
104
+ #
105
+ # #### DSL Options
106
+ #
107
+ # When using `capybara/dsl`, the following options are also available:
108
+ #
109
+ # - **default_driver** (Symbol = `:rack_test`) - The name of the driver to use by default.
110
+ # - **javascript_driver** (Symbol = `:selenium`) - The name of a driver to use for JavaScript enabled tests.
95
111
  #
96
112
  def configure
97
- yield ConfigureDeprecator.new(config)
113
+ yield config
98
114
  end
99
115
 
100
116
  ##
@@ -111,7 +127,7 @@ module Capybara
111
127
  # @yieldreturn [Capybara::Driver::Base] A Capybara driver instance
112
128
  #
113
129
  def register_driver(name, &block)
114
- drivers[name] = block
130
+ drivers.send(:register, name, block)
115
131
  end
116
132
 
117
133
  ##
@@ -128,10 +144,9 @@ module Capybara
128
144
  # @yieldparam [<Rack>] app The rack application that this server will contain.
129
145
  # @yieldparam port The port number the server should listen on
130
146
  # @yieldparam host The host/ip to bind to
131
- # @yieldreturn [Capybara::Driver::Base] A Capybara driver instance
132
147
  #
133
148
  def register_server(name, &block)
134
- servers[name.to_sym] = block
149
+ servers.send(:register, name.to_sym, block)
135
150
  end
136
151
 
137
152
  ##
@@ -162,8 +177,8 @@ module Capybara
162
177
  # @param [Symbol] name The name of the selector to add
163
178
  # @yield A block executed in the context of the new {Capybara::Selector}
164
179
  #
165
- def add_selector(name, &block)
166
- Capybara::Selector.add(name, &block)
180
+ def add_selector(name, **options, &block)
181
+ Capybara::Selector.add(name, **options, &block)
167
182
  end
168
183
 
169
184
  ##
@@ -173,7 +188,7 @@ module Capybara
173
188
  # button style (a class) might look like this
174
189
  #
175
190
  # Capybara.modify_selector(:button) do
176
- # filter (:style, valid_values: [:primary, :secondary]) { |node, style| node[:class].split.include? "btn-#{style}" }
191
+ # filter (:btn_style, valid_values: [:primary, :secondary]) { |node, style| node[:class].split.include? "btn-#{style}" }
177
192
  # end
178
193
  #
179
194
  #
@@ -185,30 +200,26 @@ module Capybara
185
200
  end
186
201
 
187
202
  def drivers
188
- @drivers ||= {}
203
+ @drivers ||= RegistrationContainer.new
189
204
  end
190
205
 
191
206
  def servers
192
- @servers ||= {}
207
+ @servers ||= RegistrationContainer.new
193
208
  end
194
209
 
195
- ##
196
- #
197
210
  # Wraps the given string, which should contain an HTML document or fragment
198
211
  # in a {Capybara::Node::Simple} which exposes all {Capybara::Node::Matchers},
199
212
  # {Capybara::Node::Finders} and {Capybara::Node::DocumentMatchers}. This allows you to query
200
213
  # any string containing HTML in the exact same way you would query the current document in a Capybara
201
214
  # session.
202
215
  #
203
- # Example: A single element
204
- #
216
+ # @example A single element
205
217
  # node = Capybara.string('<a href="foo">bar</a>')
206
218
  # anchor = node.first('a')
207
219
  # anchor[:href] #=> 'foo'
208
220
  # anchor.text #=> 'bar'
209
221
  #
210
- # Example: Multiple elements
211
- #
222
+ # @example Multiple elements
212
223
  # node = Capybara.string <<-HTML
213
224
  # <ul>
214
225
  # <li id="home">Home</li>
@@ -238,7 +249,7 @@ module Capybara
238
249
  # @param [Integer] port The port to run the application on
239
250
  #
240
251
  def run_default_server(app, port)
241
- servers[:webrick].call(app, port, server_host)
252
+ servers[:puma].call(app, port, server_host)
242
253
  end
243
254
 
244
255
  ##
@@ -296,12 +307,12 @@ module Capybara
296
307
 
297
308
  ##
298
309
  #
299
- # The current Capybara::Session based on what is set as Capybara.app and Capybara.current_driver
310
+ # The current {Capybara::Session} based on what is set as {app} and {current_driver}.
300
311
  #
301
312
  # @return [Capybara::Session] The currently used session
302
313
  #
303
314
  def current_session
304
- session_pool["#{current_driver}:#{session_name}:#{app.object_id}"] ||= Capybara::Session.new(current_driver, app)
315
+ specified_session || session_pool["#{current_driver}:#{session_name}:#{app.object_id}"]
305
316
  end
306
317
 
307
318
  ##
@@ -310,7 +321,7 @@ module Capybara
310
321
  # as cookies.
311
322
  #
312
323
  def reset_sessions!
313
- #reset in reverse so sessions that started servers are reset last
324
+ # reset in reverse so sessions that started servers are reset last
314
325
  session_pool.reverse_each { |_mode, session| session.reset! }
315
326
  end
316
327
  alias_method :reset!, :reset_sessions!
@@ -339,22 +350,31 @@ module Capybara
339
350
 
340
351
  ##
341
352
  #
342
- # Yield a block using a specific session name.
353
+ # Yield a block using a specific session name or {Capybara::Session} instance.
343
354
  #
344
- def using_session(name)
355
+ def using_session(name_or_session, &block)
356
+ previous_session = current_session
345
357
  previous_session_info = {
358
+ specified_session: specified_session,
346
359
  session_name: session_name,
347
360
  current_driver: current_driver,
348
361
  app: app
349
362
  }
350
- self.session_name = name
351
- yield
352
- ensure
353
- self.session_name = previous_session_info[:session_name]
354
- if threadsafe
355
- self.current_driver = previous_session_info[:current_driver]
356
- self.app = previous_session_info[:app]
363
+ self.specified_session = self.session_name = nil
364
+ if name_or_session.is_a? Capybara::Session
365
+ self.specified_session = name_or_session
366
+ else
367
+ self.session_name = name_or_session
368
+ end
369
+
370
+ if block.arity.zero?
371
+ yield
372
+ else
373
+ yield current_session, previous_session
357
374
  end
375
+ ensure
376
+ self.session_name, self.specified_session = previous_session_info.values_at(:session_name, :specified_session)
377
+ self.current_driver, self.app = previous_session_info.values_at(:current_driver, :app) if threadsafe
358
378
  end
359
379
 
360
380
  ##
@@ -364,10 +384,22 @@ module Capybara
364
384
  # @param [String] html The raw html
365
385
  # @return [Nokogiri::HTML::Document] HTML document
366
386
  #
367
- def HTML(html)
368
- Nokogiri::HTML(html).tap do |document|
387
+ def HTML(html) # rubocop:disable Naming/MethodName
388
+ # Nokogiri >= 1.12.0 or Nokogumbo installed and allowed for use
389
+ html_parser, using_html5 = if defined?(Nokogiri::HTML5) && Capybara.use_html5_parsing
390
+ [Nokogiri::HTML5, true]
391
+ else
392
+ [defined?(Nokogiri::HTML4) ? Nokogiri::HTML4 : Nokogiri::HTML, false]
393
+ end
394
+
395
+ html_parser.parse(html).tap do |document|
396
+ document.xpath('//template').each do |template|
397
+ # template elements content is not part of the document
398
+ template.inner_html = ''
399
+ end
369
400
  document.xpath('//textarea').each do |textarea|
370
- textarea['_capybara_raw_value'] = textarea.content.sub(/\A\n/,'')
401
+ # The Nokogiri HTML5 parser already returns spec compliant contents
402
+ textarea['_capybara_raw_value'] = using_html5 ? textarea.content : textarea.content.delete_prefix("\n")
371
403
  end
372
404
  end
373
405
  end
@@ -376,18 +408,32 @@ module Capybara
376
408
  config.session_options
377
409
  end
378
410
 
379
- def included(base)
380
- base.send(:include, Capybara::DSL)
381
- warn "`include Capybara` is deprecated. Please use `include Capybara::DSL` instead."
382
- end
383
-
384
411
  private
412
+
385
413
  def config
386
414
  @config ||= Capybara::Config.new
387
415
  end
388
416
 
389
417
  def session_pool
390
- @session_pool ||= {}
418
+ @session_pool ||= Hash.new do |hash, name|
419
+ hash[name] = Capybara::Session.new(current_driver, app)
420
+ end
421
+ end
422
+
423
+ def specified_session
424
+ if threadsafe
425
+ Thread.current['capybara_specified_session']
426
+ else
427
+ @specified_session ||= nil
428
+ end
429
+ end
430
+
431
+ def specified_session=(session)
432
+ if threadsafe
433
+ Thread.current['capybara_specified_session'] = session
434
+ else
435
+ @specified_session = session
436
+ end
391
437
  end
392
438
  end
393
439
 
@@ -415,7 +461,8 @@ module Capybara
415
461
  require 'capybara/queries/match_query'
416
462
  require 'capybara/queries/ancestor_query'
417
463
  require 'capybara/queries/sibling_query'
418
- require 'capybara/query'
464
+ require 'capybara/queries/style_query'
465
+ require 'capybara/queries/active_element_query'
419
466
 
420
467
  require 'capybara/node/finders'
421
468
  require 'capybara/node/matchers'
@@ -433,25 +480,14 @@ module Capybara
433
480
  require 'capybara/rack_test/node'
434
481
  require 'capybara/rack_test/form'
435
482
  require 'capybara/rack_test/browser'
436
- require 'capybara/rack_test/css_handlers.rb'
483
+ require 'capybara/rack_test/css_handlers'
437
484
 
438
485
  require 'capybara/selenium/node'
439
486
  require 'capybara/selenium/driver'
440
487
  end
441
488
 
442
- Capybara.register_server :default do |app, port, _host|
443
- Capybara.run_default_server(app, port)
444
- end
445
-
446
- Capybara.register_server :webrick do |app, port, host, options={}|
447
- require 'rack/handler/webrick'
448
- Rack::Handler::WEBrick.run(app, {Host: host, Port: port, AccessLog: [], Logger: WEBrick::Log::new(nil, 0)}.merge(options))
449
- end
450
-
451
- Capybara.register_server :puma do |app, port, host, options={}|
452
- require 'rack/handler/puma'
453
- Rack::Handler::Puma.run(app, {Host: host, Port: port, Threads: "0:4", workers: 0, daemon: false}.merge(options))
454
- end
489
+ require 'capybara/registrations/servers'
490
+ require 'capybara/registrations/drivers'
455
491
 
456
492
  Capybara.configure do |config|
457
493
  config.always_include_port = false
@@ -460,35 +496,22 @@ Capybara.configure do |config|
460
496
  config.default_selector = :css
461
497
  config.default_max_wait_time = 2
462
498
  config.ignore_hidden_elements = true
463
- config.default_host = "http://www.example.com"
499
+ config.default_host = 'http://www.example.com'
464
500
  config.automatic_reload = true
465
501
  config.match = :smart
466
502
  config.exact = false
467
503
  config.exact_text = false
468
504
  config.raise_server_errors = true
469
- config.server_errors = [StandardError]
505
+ config.server_errors = [Exception]
470
506
  config.visible_text_only = false
471
- config.wait_on_first_by_default = false
472
507
  config.automatic_label_click = false
473
508
  config.enable_aria_label = false
509
+ config.enable_aria_role = false
474
510
  config.reuse_server = true
475
- end
476
-
477
- Capybara.register_driver :rack_test do |app|
478
- Capybara::RackTest::Driver.new(app)
479
- end
480
-
481
- Capybara.register_driver :selenium do |app|
482
- Capybara::Selenium::Driver.new(app)
483
- end
484
-
485
- Capybara.register_driver :selenium_chrome do |app|
486
- Capybara::Selenium::Driver.new(app, :browser => :chrome)
487
- end
488
-
489
- Capybara.register_driver :selenium_chrome_headless do |app|
490
- browser_options = ::Selenium::WebDriver::Chrome::Options.new()
491
- browser_options.args << '--headless'
492
- browser_options.args << '--disable-gpu'
493
- Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
511
+ config.default_set_options = {}
512
+ config.test_id = nil
513
+ config.predicates_wait = true
514
+ config.default_normalize_ws = false
515
+ config.use_html5_parsing = false
516
+ config.w3c_click_offset = false
494
517
  end
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  RSpec.describe Capybara do
6
+ include Capybara::RSpecMatchers
5
7
  describe '.string' do
6
8
  let :string do
7
- Capybara.string <<-STRING
9
+ described_class.string <<-STRING
8
10
  <html>
9
11
  <head>
10
12
  <title>simple_node</title>
@@ -45,97 +47,121 @@ RSpec.describe Capybara do
45
47
  STRING
46
48
  end
47
49
 
48
- it "allows using matchers" do
50
+ it 'allows using matchers' do
49
51
  expect(string).to have_css('#page')
50
52
  expect(string).not_to have_css('#does-not-exist')
51
53
  end
52
54
 
53
- it "allows using custom matchers" do
54
- Capybara.add_selector :lifeform do
55
+ it 'allows using custom matchers' do
56
+ described_class.add_selector :lifeform do
55
57
  xpath { |name| ".//option[contains(.,'#{name}')]" }
56
58
  end
57
- expect(string).to have_selector(:id, "page")
59
+ expect(string).to have_selector(:id, 'page')
58
60
  expect(string).not_to have_selector(:id, 'does-not-exist')
59
- expect(string).to have_selector(:lifeform, "Monkey")
60
- expect(string).not_to have_selector(:lifeform, "Gorilla")
61
+ expect(string).to have_selector(:lifeform, 'Monkey')
62
+ expect(string).not_to have_selector(:lifeform, 'Gorilla')
61
63
  end
62
64
 
63
65
  it 'allows custom matcher using css' do
64
- Capybara.add_selector :section do
66
+ described_class.add_selector :section do
65
67
  css { |css_class| "section .#{css_class}" }
66
68
  end
67
69
  expect(string).to have_selector(:section, 'subsection')
68
70
  expect(string).not_to have_selector(:section, 'section_8')
69
71
  end
70
72
 
71
- it "allows using matchers with text option" do
73
+ it 'allows using matchers with text option' do
72
74
  expect(string).to have_css('h1', text: 'Totally awesome')
73
75
  expect(string).not_to have_css('h1', text: 'Not so awesome')
74
76
  end
75
77
 
76
- it "allows finding only visible nodes" do
78
+ it 'allows finding only visible nodes' do
77
79
  expect(string.all(:css, '#secret', visible: true)).to be_empty
78
80
  expect(string.all(:css, '#secret', visible: false).size).to eq(1)
79
81
  end
80
82
 
81
- it "allows finding elements and extracting text from them" do
83
+ it 'allows finding elements and extracting text from them' do
82
84
  expect(string.find('//h1').text).to eq('Totally awesome')
83
85
  end
84
86
 
85
- it "allows finding elements and extracting attributes from them" do
87
+ it 'allows finding elements and extracting attributes from them' do
86
88
  expect(string.find('//h1')[:data]).to eq('fantastic')
87
89
  end
88
90
 
89
- it "allows finding elements and extracting the tag name from them" do
91
+ it 'allows finding elements and extracting the tag name from them' do
90
92
  expect(string.find('//h1').tag_name).to eq('h1')
91
93
  end
92
94
 
93
- it "allows finding elements and extracting the path" do
95
+ it 'allows finding elements and extracting the path' do
94
96
  expect(string.find('//h1').path).to eq('/html/body/div/div[1]/h1')
95
97
  end
96
98
 
97
- it "allows finding elements and extracting the path" do
99
+ it 'allows finding elements and extracting the value' do
98
100
  expect(string.find('//div/input').value).to eq('bar')
99
101
  expect(string.find('//select').value).to eq('Capybara')
100
102
  end
101
103
 
102
- it "allows finding elements and checking if they are visible" do
104
+ it 'allows finding elements and checking if they are visible' do
103
105
  expect(string.find('//h1')).to be_visible
104
- expect(string.find(:css, "#secret", visible: false)).not_to be_visible
106
+ expect(string.find(:css, '#secret', visible: false)).not_to be_visible
105
107
  end
106
108
 
107
- it "allows finding elements and checking if they are disabled" do
109
+ it 'allows finding elements and checking if they are disabled' do
108
110
  expect(string.find('//form/input[@name="bleh"]')).to be_disabled
109
111
  expect(string.find('//form/input[@name="meh"]')).not_to be_disabled
110
112
  end
111
113
 
112
- describe "#title" do
113
- it "returns the page title" do
114
- expect(string.title).to eq("simple_node")
114
+ it 'allows finding siblings' do
115
+ h1 = string.find(:css, 'h1')
116
+ expect(h1).to have_sibling(:css, 'p', text: 'Yes it is')
117
+ expect(h1).not_to have_sibling(:css, 'p', text: 'Jonas Nicklas')
118
+ end
119
+
120
+ it 'allows finding ancestor' do
121
+ h1 = string.find(:css, 'h1')
122
+ expect(h1).to have_ancestor(:css, '#content')
123
+ expect(h1).not_to have_ancestor(:css, '#footer')
124
+ end
125
+
126
+ it 'drops illegal fragments when using gumbo' do
127
+ skip 'libxml is less strict than Gumbo' unless Nokogiri.respond_to?(:HTML5)
128
+ described_class.use_html5_parsing = true
129
+ expect(described_class.string('<td>1</td>')).not_to have_css('td')
130
+ end
131
+
132
+ it 'can disable use of HTML5 parsing' do
133
+ skip "Test doesn't make sense unlesss HTML5 parsing is loaded (Nokogumbo or Nokogiri >= 1.12.0)" unless Nokogiri.respond_to?(:HTML5)
134
+ described_class.use_html5_parsing = false
135
+ expect(described_class.string('<td>1</td>')).to have_css('td')
136
+ end
137
+
138
+ describe '#title' do
139
+ it 'returns the page title' do
140
+ expect(string.title).to eq('simple_node')
115
141
  end
116
142
  end
117
143
 
118
- describe "#has_title?" do
119
- it "returns whether the page has the given title" do
120
- expect(string.has_title?('simple_node')).to be_truthy
121
- expect(string.has_title?('monkey')).to be_falsey
144
+ describe '#has_title?' do
145
+ it 'returns whether the page has the given title' do
146
+ expect(string.has_title?('simple_node')).to be true
147
+ expect(string.has_title?('monkey')).to be false
122
148
  end
123
149
 
124
- it "allows regexp matches" do
125
- expect(string.has_title?(/s[a-z]+_node/)).to be_truthy
126
- expect(string.has_title?(/monkey/)).to be_falsey
150
+ it 'allows regexp matches' do
151
+ expect(string.has_title?(/s[a-z]+_node/)).to be true
152
+ expect(string.has_title?(/monkey/)).to be false
127
153
  end
128
154
  end
129
155
 
130
156
  describe '#has_no_title?' do
131
- it "returns whether the page does not have the given title" do
132
- expect(string.has_no_title?('simple_node')).to be_falsey
133
- expect(string.has_no_title?('monkey')).to be_truthy
157
+ it 'returns whether the page does not have the given title' do
158
+ expect(string.has_no_title?('simple_node')).to be false
159
+ expect(string.has_no_title?('monkey')).to be true
134
160
  end
135
161
 
136
- it "allows regexp matches" do
137
- expect(string.has_no_title?(/s[a-z]+_node/)).to be_falsey
138
- expect(string.has_no_title?(/monkey/)).to be_truthy
162
+ it 'allows regexp matches' do
163
+ expect(string.has_no_title?(/s[a-z]+_node/)).to be false
164
+ expect(string.has_no_title?(/monkey/)).to be true
139
165
  end
140
166
  end
141
167
  end