mega-max-rb 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. checksums.yaml +7 -0
  2. data/capybara-3.40.0/History.md +2043 -0
  3. data/capybara-3.40.0/License.txt +22 -0
  4. data/capybara-3.40.0/README.md +1264 -0
  5. data/capybara-3.40.0/lib/capybara/config.rb +104 -0
  6. data/capybara-3.40.0/lib/capybara/cucumber.rb +27 -0
  7. data/capybara-3.40.0/lib/capybara/driver/base.rb +178 -0
  8. data/capybara-3.40.0/lib/capybara/driver/node.rb +143 -0
  9. data/capybara-3.40.0/lib/capybara/dsl.rb +59 -0
  10. data/capybara-3.40.0/lib/capybara/helpers.rb +127 -0
  11. data/capybara-3.40.0/lib/capybara/minitest/spec.rb +279 -0
  12. data/capybara-3.40.0/lib/capybara/minitest.rb +398 -0
  13. data/capybara-3.40.0/lib/capybara/node/actions.rb +420 -0
  14. data/capybara-3.40.0/lib/capybara/node/base.rb +144 -0
  15. data/capybara-3.40.0/lib/capybara/node/document.rb +48 -0
  16. data/capybara-3.40.0/lib/capybara/node/document_matchers.rb +67 -0
  17. data/capybara-3.40.0/lib/capybara/node/element.rb +613 -0
  18. data/capybara-3.40.0/lib/capybara/node/finders.rb +335 -0
  19. data/capybara-3.40.0/lib/capybara/node/matchers.rb +908 -0
  20. data/capybara-3.40.0/lib/capybara/node/simple.rb +216 -0
  21. data/capybara-3.40.0/lib/capybara/node/whitespace_normalizer.rb +81 -0
  22. data/capybara-3.40.0/lib/capybara/queries/active_element_query.rb +18 -0
  23. data/capybara-3.40.0/lib/capybara/queries/ancestor_query.rb +28 -0
  24. data/capybara-3.40.0/lib/capybara/queries/base_query.rb +106 -0
  25. data/capybara-3.40.0/lib/capybara/queries/current_path_query.rb +61 -0
  26. data/capybara-3.40.0/lib/capybara/queries/match_query.rb +26 -0
  27. data/capybara-3.40.0/lib/capybara/queries/selector_query.rb +761 -0
  28. data/capybara-3.40.0/lib/capybara/queries/sibling_query.rb +27 -0
  29. data/capybara-3.40.0/lib/capybara/queries/style_query.rb +45 -0
  30. data/capybara-3.40.0/lib/capybara/queries/text_query.rb +116 -0
  31. data/capybara-3.40.0/lib/capybara/queries/title_query.rb +39 -0
  32. data/capybara-3.40.0/lib/capybara/rack_test/browser.rb +200 -0
  33. data/capybara-3.40.0/lib/capybara/rack_test/css_handlers.rb +13 -0
  34. data/capybara-3.40.0/lib/capybara/rack_test/driver.rb +110 -0
  35. data/capybara-3.40.0/lib/capybara/rack_test/errors.rb +6 -0
  36. data/capybara-3.40.0/lib/capybara/rack_test/form.rb +149 -0
  37. data/capybara-3.40.0/lib/capybara/rack_test/node.rb +324 -0
  38. data/capybara-3.40.0/lib/capybara/rails.rb +16 -0
  39. data/capybara-3.40.0/lib/capybara/registration_container.rb +41 -0
  40. data/capybara-3.40.0/lib/capybara/registrations/drivers.rb +42 -0
  41. data/capybara-3.40.0/lib/capybara/registrations/patches/puma_ssl.rb +29 -0
  42. data/capybara-3.40.0/lib/capybara/registrations/servers.rb +66 -0
  43. data/capybara-3.40.0/lib/capybara/result.rb +186 -0
  44. data/capybara-3.40.0/lib/capybara/rspec/features.rb +23 -0
  45. data/capybara-3.40.0/lib/capybara/rspec/matcher_proxies.rb +82 -0
  46. data/capybara-3.40.0/lib/capybara/rspec/matchers/base.rb +113 -0
  47. data/capybara-3.40.0/lib/capybara/rspec/matchers/become_closed.rb +33 -0
  48. data/capybara-3.40.0/lib/capybara/rspec/matchers/compound.rb +88 -0
  49. data/capybara-3.40.0/lib/capybara/rspec/matchers/count_sugar.rb +37 -0
  50. data/capybara-3.40.0/lib/capybara/rspec/matchers/have_ancestor.rb +28 -0
  51. data/capybara-3.40.0/lib/capybara/rspec/matchers/have_current_path.rb +29 -0
  52. data/capybara-3.40.0/lib/capybara/rspec/matchers/have_selector.rb +69 -0
  53. data/capybara-3.40.0/lib/capybara/rspec/matchers/have_sibling.rb +27 -0
  54. data/capybara-3.40.0/lib/capybara/rspec/matchers/have_text.rb +33 -0
  55. data/capybara-3.40.0/lib/capybara/rspec/matchers/have_title.rb +29 -0
  56. data/capybara-3.40.0/lib/capybara/rspec/matchers/match_selector.rb +27 -0
  57. data/capybara-3.40.0/lib/capybara/rspec/matchers/match_style.rb +43 -0
  58. data/capybara-3.40.0/lib/capybara/rspec/matchers/spatial_sugar.rb +39 -0
  59. data/capybara-3.40.0/lib/capybara/rspec/matchers.rb +207 -0
  60. data/capybara-3.40.0/lib/capybara/rspec.rb +31 -0
  61. data/capybara-3.40.0/lib/capybara/selector/builders/css_builder.rb +84 -0
  62. data/capybara-3.40.0/lib/capybara/selector/builders/xpath_builder.rb +71 -0
  63. data/capybara-3.40.0/lib/capybara/selector/css.rb +102 -0
  64. data/capybara-3.40.0/lib/capybara/selector/definition/button.rb +68 -0
  65. data/capybara-3.40.0/lib/capybara/selector/definition/checkbox.rb +26 -0
  66. data/capybara-3.40.0/lib/capybara/selector/definition/css.rb +10 -0
  67. data/capybara-3.40.0/lib/capybara/selector/definition/datalist_input.rb +35 -0
  68. data/capybara-3.40.0/lib/capybara/selector/definition/datalist_option.rb +25 -0
  69. data/capybara-3.40.0/lib/capybara/selector/definition/element.rb +28 -0
  70. data/capybara-3.40.0/lib/capybara/selector/definition/field.rb +40 -0
  71. data/capybara-3.40.0/lib/capybara/selector/definition/fieldset.rb +14 -0
  72. data/capybara-3.40.0/lib/capybara/selector/definition/file_field.rb +13 -0
  73. data/capybara-3.40.0/lib/capybara/selector/definition/fillable_field.rb +33 -0
  74. data/capybara-3.40.0/lib/capybara/selector/definition/frame.rb +17 -0
  75. data/capybara-3.40.0/lib/capybara/selector/definition/id.rb +6 -0
  76. data/capybara-3.40.0/lib/capybara/selector/definition/label.rb +62 -0
  77. data/capybara-3.40.0/lib/capybara/selector/definition/link.rb +55 -0
  78. data/capybara-3.40.0/lib/capybara/selector/definition/link_or_button.rb +16 -0
  79. data/capybara-3.40.0/lib/capybara/selector/definition/option.rb +27 -0
  80. data/capybara-3.40.0/lib/capybara/selector/definition/radio_button.rb +27 -0
  81. data/capybara-3.40.0/lib/capybara/selector/definition/select.rb +81 -0
  82. data/capybara-3.40.0/lib/capybara/selector/definition/table.rb +109 -0
  83. data/capybara-3.40.0/lib/capybara/selector/definition/table_row.rb +21 -0
  84. data/capybara-3.40.0/lib/capybara/selector/definition/xpath.rb +5 -0
  85. data/capybara-3.40.0/lib/capybara/selector/definition.rb +280 -0
  86. data/capybara-3.40.0/lib/capybara/selector/filter.rb +5 -0
  87. data/capybara-3.40.0/lib/capybara/selector/filter_set.rb +121 -0
  88. data/capybara-3.40.0/lib/capybara/selector/filters/base.rb +77 -0
  89. data/capybara-3.40.0/lib/capybara/selector/filters/expression_filter.rb +22 -0
  90. data/capybara-3.40.0/lib/capybara/selector/filters/locator_filter.rb +29 -0
  91. data/capybara-3.40.0/lib/capybara/selector/filters/node_filter.rb +31 -0
  92. data/capybara-3.40.0/lib/capybara/selector/regexp_disassembler.rb +211 -0
  93. data/capybara-3.40.0/lib/capybara/selector/selector.rb +159 -0
  94. data/capybara-3.40.0/lib/capybara/selector/xpath_extensions.rb +17 -0
  95. data/capybara-3.40.0/lib/capybara/selector.rb +494 -0
  96. data/capybara-3.40.0/lib/capybara/selenium/atoms/getAttribute.min.js +1 -0
  97. data/capybara-3.40.0/lib/capybara/selenium/atoms/isDisplayed.min.js +1 -0
  98. data/capybara-3.40.0/lib/capybara/selenium/atoms/src/getAttribute.js +161 -0
  99. data/capybara-3.40.0/lib/capybara/selenium/atoms/src/isDisplayed.js +454 -0
  100. data/capybara-3.40.0/lib/capybara/selenium/driver.rb +517 -0
  101. data/capybara-3.40.0/lib/capybara/selenium/driver_specializations/chrome_driver.rb +117 -0
  102. data/capybara-3.40.0/lib/capybara/selenium/driver_specializations/edge_driver.rb +128 -0
  103. data/capybara-3.40.0/lib/capybara/selenium/driver_specializations/firefox_driver.rb +84 -0
  104. data/capybara-3.40.0/lib/capybara/selenium/driver_specializations/internet_explorer_driver.rb +26 -0
  105. data/capybara-3.40.0/lib/capybara/selenium/driver_specializations/safari_driver.rb +24 -0
  106. data/capybara-3.40.0/lib/capybara/selenium/extensions/file_input_click_emulation.rb +34 -0
  107. data/capybara-3.40.0/lib/capybara/selenium/extensions/find.rb +110 -0
  108. data/capybara-3.40.0/lib/capybara/selenium/extensions/html5_drag.rb +229 -0
  109. data/capybara-3.40.0/lib/capybara/selenium/extensions/modifier_keys_stack.rb +28 -0
  110. data/capybara-3.40.0/lib/capybara/selenium/extensions/scroll.rb +76 -0
  111. data/capybara-3.40.0/lib/capybara/selenium/node.rb +636 -0
  112. data/capybara-3.40.0/lib/capybara/selenium/nodes/chrome_node.rb +125 -0
  113. data/capybara-3.40.0/lib/capybara/selenium/nodes/edge_node.rb +110 -0
  114. data/capybara-3.40.0/lib/capybara/selenium/nodes/firefox_node.rb +136 -0
  115. data/capybara-3.40.0/lib/capybara/selenium/nodes/ie_node.rb +22 -0
  116. data/capybara-3.40.0/lib/capybara/selenium/nodes/safari_node.rb +118 -0
  117. data/capybara-3.40.0/lib/capybara/selenium/patches/atoms.rb +18 -0
  118. data/capybara-3.40.0/lib/capybara/selenium/patches/is_displayed.rb +16 -0
  119. data/capybara-3.40.0/lib/capybara/selenium/patches/logs.rb +45 -0
  120. data/capybara-3.40.0/lib/capybara/selenium/patches/pause_duration_fix.rb +9 -0
  121. data/capybara-3.40.0/lib/capybara/selenium/patches/persistent_client.rb +20 -0
  122. data/capybara-3.40.0/lib/capybara/server/animation_disabler.rb +80 -0
  123. data/capybara-3.40.0/lib/capybara/server/checker.rb +44 -0
  124. data/capybara-3.40.0/lib/capybara/server/middleware.rb +71 -0
  125. data/capybara-3.40.0/lib/capybara/server.rb +126 -0
  126. data/capybara-3.40.0/lib/capybara/session/config.rb +128 -0
  127. data/capybara-3.40.0/lib/capybara/session/matchers.rb +87 -0
  128. data/capybara-3.40.0/lib/capybara/session.rb +951 -0
  129. data/capybara-3.40.0/lib/capybara/spec/fixtures/another_test_file.txt +1 -0
  130. data/capybara-3.40.0/lib/capybara/spec/fixtures/capybara.jpg +3 -0
  131. data/capybara-3.40.0/lib/capybara/spec/fixtures/no_extension +1 -0
  132. data/capybara-3.40.0/lib/capybara/spec/fixtures/test_file.txt +1 -0
  133. data/capybara-3.40.0/lib/capybara/spec/public/jquery-ui.js +13 -0
  134. data/capybara-3.40.0/lib/capybara/spec/public/jquery.js +5 -0
  135. data/capybara-3.40.0/lib/capybara/spec/public/offset.js +6 -0
  136. data/capybara-3.40.0/lib/capybara/spec/public/test.js +284 -0
  137. data/capybara-3.40.0/lib/capybara/spec/session/accept_alert_spec.rb +81 -0
  138. data/capybara-3.40.0/lib/capybara/spec/session/accept_confirm_spec.rb +32 -0
  139. data/capybara-3.40.0/lib/capybara/spec/session/accept_prompt_spec.rb +78 -0
  140. data/capybara-3.40.0/lib/capybara/spec/session/active_element_spec.rb +31 -0
  141. data/capybara-3.40.0/lib/capybara/spec/session/all_spec.rb +274 -0
  142. data/capybara-3.40.0/lib/capybara/spec/session/ancestor_spec.rb +88 -0
  143. data/capybara-3.40.0/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +140 -0
  144. data/capybara-3.40.0/lib/capybara/spec/session/assert_current_path_spec.rb +75 -0
  145. data/capybara-3.40.0/lib/capybara/spec/session/assert_selector_spec.rb +143 -0
  146. data/capybara-3.40.0/lib/capybara/spec/session/assert_style_spec.rb +26 -0
  147. data/capybara-3.40.0/lib/capybara/spec/session/assert_text_spec.rb +258 -0
  148. data/capybara-3.40.0/lib/capybara/spec/session/assert_title_spec.rb +93 -0
  149. data/capybara-3.40.0/lib/capybara/spec/session/attach_file_spec.rb +222 -0
  150. data/capybara-3.40.0/lib/capybara/spec/session/body_spec.rb +23 -0
  151. data/capybara-3.40.0/lib/capybara/spec/session/check_spec.rb +251 -0
  152. data/capybara-3.40.0/lib/capybara/spec/session/choose_spec.rb +127 -0
  153. data/capybara-3.40.0/lib/capybara/spec/session/click_button_spec.rb +517 -0
  154. data/capybara-3.40.0/lib/capybara/spec/session/click_link_or_button_spec.rb +138 -0
  155. data/capybara-3.40.0/lib/capybara/spec/session/click_link_spec.rb +240 -0
  156. data/capybara-3.40.0/lib/capybara/spec/session/current_scope_spec.rb +31 -0
  157. data/capybara-3.40.0/lib/capybara/spec/session/current_url_spec.rb +125 -0
  158. data/capybara-3.40.0/lib/capybara/spec/session/dismiss_confirm_spec.rb +36 -0
  159. data/capybara-3.40.0/lib/capybara/spec/session/dismiss_prompt_spec.rb +21 -0
  160. data/capybara-3.40.0/lib/capybara/spec/session/element/assert_match_selector_spec.rb +38 -0
  161. data/capybara-3.40.0/lib/capybara/spec/session/element/match_css_spec.rb +31 -0
  162. data/capybara-3.40.0/lib/capybara/spec/session/element/match_xpath_spec.rb +25 -0
  163. data/capybara-3.40.0/lib/capybara/spec/session/element/matches_selector_spec.rb +120 -0
  164. data/capybara-3.40.0/lib/capybara/spec/session/evaluate_async_script_spec.rb +23 -0
  165. data/capybara-3.40.0/lib/capybara/spec/session/evaluate_script_spec.rb +49 -0
  166. data/capybara-3.40.0/lib/capybara/spec/session/execute_script_spec.rb +28 -0
  167. data/capybara-3.40.0/lib/capybara/spec/session/fill_in_spec.rb +292 -0
  168. data/capybara-3.40.0/lib/capybara/spec/session/find_button_spec.rb +74 -0
  169. data/capybara-3.40.0/lib/capybara/spec/session/find_by_id_spec.rb +33 -0
  170. data/capybara-3.40.0/lib/capybara/spec/session/find_field_spec.rb +113 -0
  171. data/capybara-3.40.0/lib/capybara/spec/session/find_link_spec.rb +80 -0
  172. data/capybara-3.40.0/lib/capybara/spec/session/find_spec.rb +545 -0
  173. data/capybara-3.40.0/lib/capybara/spec/session/first_spec.rb +156 -0
  174. data/capybara-3.40.0/lib/capybara/spec/session/frame/frame_title_spec.rb +23 -0
  175. data/capybara-3.40.0/lib/capybara/spec/session/frame/frame_url_spec.rb +23 -0
  176. data/capybara-3.40.0/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +116 -0
  177. data/capybara-3.40.0/lib/capybara/spec/session/frame/within_frame_spec.rb +114 -0
  178. data/capybara-3.40.0/lib/capybara/spec/session/go_back_spec.rb +12 -0
  179. data/capybara-3.40.0/lib/capybara/spec/session/go_forward_spec.rb +14 -0
  180. data/capybara-3.40.0/lib/capybara/spec/session/has_all_selectors_spec.rb +69 -0
  181. data/capybara-3.40.0/lib/capybara/spec/session/has_ancestor_spec.rb +46 -0
  182. data/capybara-3.40.0/lib/capybara/spec/session/has_any_selectors_spec.rb +29 -0
  183. data/capybara-3.40.0/lib/capybara/spec/session/has_button_spec.rb +150 -0
  184. data/capybara-3.40.0/lib/capybara/spec/session/has_css_spec.rb +375 -0
  185. data/capybara-3.40.0/lib/capybara/spec/session/has_current_path_spec.rb +151 -0
  186. data/capybara-3.40.0/lib/capybara/spec/session/has_element_spec.rb +47 -0
  187. data/capybara-3.40.0/lib/capybara/spec/session/has_field_spec.rb +389 -0
  188. data/capybara-3.40.0/lib/capybara/spec/session/has_link_spec.rb +79 -0
  189. data/capybara-3.40.0/lib/capybara/spec/session/has_none_selectors_spec.rb +78 -0
  190. data/capybara-3.40.0/lib/capybara/spec/session/has_select_spec.rb +316 -0
  191. data/capybara-3.40.0/lib/capybara/spec/session/has_selector_spec.rb +217 -0
  192. data/capybara-3.40.0/lib/capybara/spec/session/has_sibling_spec.rb +50 -0
  193. data/capybara-3.40.0/lib/capybara/spec/session/has_table_spec.rb +209 -0
  194. data/capybara-3.40.0/lib/capybara/spec/session/has_text_spec.rb +375 -0
  195. data/capybara-3.40.0/lib/capybara/spec/session/has_title_spec.rb +71 -0
  196. data/capybara-3.40.0/lib/capybara/spec/session/has_xpath_spec.rb +149 -0
  197. data/capybara-3.40.0/lib/capybara/spec/session/headers_spec.rb +8 -0
  198. data/capybara-3.40.0/lib/capybara/spec/session/html_spec.rb +47 -0
  199. data/capybara-3.40.0/lib/capybara/spec/session/matches_style_spec.rb +37 -0
  200. data/capybara-3.40.0/lib/capybara/spec/session/node_spec.rb +1399 -0
  201. data/capybara-3.40.0/lib/capybara/spec/session/node_wrapper_spec.rb +39 -0
  202. data/capybara-3.40.0/lib/capybara/spec/session/refresh_spec.rb +34 -0
  203. data/capybara-3.40.0/lib/capybara/spec/session/reset_session_spec.rb +161 -0
  204. data/capybara-3.40.0/lib/capybara/spec/session/response_code_spec.rb +8 -0
  205. data/capybara-3.40.0/lib/capybara/spec/session/save_and_open_page_spec.rb +21 -0
  206. data/capybara-3.40.0/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +43 -0
  207. data/capybara-3.40.0/lib/capybara/spec/session/save_page_spec.rb +110 -0
  208. data/capybara-3.40.0/lib/capybara/spec/session/save_screenshot_spec.rb +55 -0
  209. data/capybara-3.40.0/lib/capybara/spec/session/screenshot_spec.rb +18 -0
  210. data/capybara-3.40.0/lib/capybara/spec/session/scroll_spec.rb +119 -0
  211. data/capybara-3.40.0/lib/capybara/spec/session/select_spec.rb +229 -0
  212. data/capybara-3.40.0/lib/capybara/spec/session/selectors_spec.rb +98 -0
  213. data/capybara-3.40.0/lib/capybara/spec/session/sibling_spec.rb +52 -0
  214. data/capybara-3.40.0/lib/capybara/spec/session/text_spec.rb +74 -0
  215. data/capybara-3.40.0/lib/capybara/spec/session/title_spec.rb +29 -0
  216. data/capybara-3.40.0/lib/capybara/spec/session/uncheck_spec.rb +100 -0
  217. data/capybara-3.40.0/lib/capybara/spec/session/unselect_spec.rb +116 -0
  218. data/capybara-3.40.0/lib/capybara/spec/session/visit_spec.rb +224 -0
  219. data/capybara-3.40.0/lib/capybara/spec/session/window/become_closed_spec.rb +89 -0
  220. data/capybara-3.40.0/lib/capybara/spec/session/window/current_window_spec.rb +28 -0
  221. data/capybara-3.40.0/lib/capybara/spec/session/window/open_new_window_spec.rb +31 -0
  222. data/capybara-3.40.0/lib/capybara/spec/session/window/switch_to_window_spec.rb +132 -0
  223. data/capybara-3.40.0/lib/capybara/spec/session/window/window_opened_by_spec.rb +99 -0
  224. data/capybara-3.40.0/lib/capybara/spec/session/window/window_spec.rb +203 -0
  225. data/capybara-3.40.0/lib/capybara/spec/session/window/windows_spec.rb +34 -0
  226. data/capybara-3.40.0/lib/capybara/spec/session/window/within_window_spec.rb +157 -0
  227. data/capybara-3.40.0/lib/capybara/spec/session/within_spec.rb +212 -0
  228. data/capybara-3.40.0/lib/capybara/spec/spec_helper.rb +141 -0
  229. data/capybara-3.40.0/lib/capybara/spec/test_app.rb +305 -0
  230. data/capybara-3.40.0/lib/capybara/spec/views/animated.erb +49 -0
  231. data/capybara-3.40.0/lib/capybara/spec/views/buttons.erb +5 -0
  232. data/capybara-3.40.0/lib/capybara/spec/views/fieldsets.erb +30 -0
  233. data/capybara-3.40.0/lib/capybara/spec/views/form.erb +738 -0
  234. data/capybara-3.40.0/lib/capybara/spec/views/frame_child.erb +18 -0
  235. data/capybara-3.40.0/lib/capybara/spec/views/frame_one.erb +10 -0
  236. data/capybara-3.40.0/lib/capybara/spec/views/frame_parent.erb +9 -0
  237. data/capybara-3.40.0/lib/capybara/spec/views/frame_two.erb +9 -0
  238. data/capybara-3.40.0/lib/capybara/spec/views/header_links.erb +8 -0
  239. data/capybara-3.40.0/lib/capybara/spec/views/host_links.erb +13 -0
  240. data/capybara-3.40.0/lib/capybara/spec/views/initial_alert.erb +11 -0
  241. data/capybara-3.40.0/lib/capybara/spec/views/layout.erb +10 -0
  242. data/capybara-3.40.0/lib/capybara/spec/views/obscured.erb +47 -0
  243. data/capybara-3.40.0/lib/capybara/spec/views/offset.erb +33 -0
  244. data/capybara-3.40.0/lib/capybara/spec/views/path.erb +13 -0
  245. data/capybara-3.40.0/lib/capybara/spec/views/popup_one.erb +9 -0
  246. data/capybara-3.40.0/lib/capybara/spec/views/popup_two.erb +9 -0
  247. data/capybara-3.40.0/lib/capybara/spec/views/postback.erb +14 -0
  248. data/capybara-3.40.0/lib/capybara/spec/views/react.erb +45 -0
  249. data/capybara-3.40.0/lib/capybara/spec/views/scroll.erb +21 -0
  250. data/capybara-3.40.0/lib/capybara/spec/views/spatial.erb +31 -0
  251. data/capybara-3.40.0/lib/capybara/spec/views/tables.erb +130 -0
  252. data/capybara-3.40.0/lib/capybara/spec/views/with_animation.erb +81 -0
  253. data/capybara-3.40.0/lib/capybara/spec/views/with_base_tag.erb +11 -0
  254. data/capybara-3.40.0/lib/capybara/spec/views/with_count.erb +8 -0
  255. data/capybara-3.40.0/lib/capybara/spec/views/with_dragula.erb +24 -0
  256. data/capybara-3.40.0/lib/capybara/spec/views/with_fixed_header_footer.erb +18 -0
  257. data/capybara-3.40.0/lib/capybara/spec/views/with_hover.erb +24 -0
  258. data/capybara-3.40.0/lib/capybara/spec/views/with_hover1.erb +10 -0
  259. data/capybara-3.40.0/lib/capybara/spec/views/with_html.erb +210 -0
  260. data/capybara-3.40.0/lib/capybara/spec/views/with_html5_svg.erb +20 -0
  261. data/capybara-3.40.0/lib/capybara/spec/views/with_html_entities.erb +2 -0
  262. data/capybara-3.40.0/lib/capybara/spec/views/with_jquery_animation.erb +24 -0
  263. data/capybara-3.40.0/lib/capybara/spec/views/with_js.erb +162 -0
  264. data/capybara-3.40.0/lib/capybara/spec/views/with_jstree.erb +26 -0
  265. data/capybara-3.40.0/lib/capybara/spec/views/with_namespace.erb +21 -0
  266. data/capybara-3.40.0/lib/capybara/spec/views/with_scope.erb +42 -0
  267. data/capybara-3.40.0/lib/capybara/spec/views/with_scope_other.erb +6 -0
  268. data/capybara-3.40.0/lib/capybara/spec/views/with_shadow.erb +31 -0
  269. data/capybara-3.40.0/lib/capybara/spec/views/with_simple_html.erb +2 -0
  270. data/capybara-3.40.0/lib/capybara/spec/views/with_slow_unload.erb +18 -0
  271. data/capybara-3.40.0/lib/capybara/spec/views/with_sortable_js.erb +21 -0
  272. data/capybara-3.40.0/lib/capybara/spec/views/with_unload_alert.erb +15 -0
  273. data/capybara-3.40.0/lib/capybara/spec/views/with_windows.erb +54 -0
  274. data/capybara-3.40.0/lib/capybara/spec/views/within_frames.erb +15 -0
  275. data/capybara-3.40.0/lib/capybara/version.rb +5 -0
  276. data/capybara-3.40.0/lib/capybara/window.rb +142 -0
  277. data/capybara-3.40.0/lib/capybara.rb +521 -0
  278. data/capybara-3.40.0/spec/basic_node_spec.rb +168 -0
  279. data/capybara-3.40.0/spec/capybara_spec.rb +124 -0
  280. data/capybara-3.40.0/spec/counter_spec.rb +35 -0
  281. data/capybara-3.40.0/spec/css_builder_spec.rb +101 -0
  282. data/capybara-3.40.0/spec/css_splitter_spec.rb +38 -0
  283. data/capybara-3.40.0/spec/dsl_spec.rb +291 -0
  284. data/capybara-3.40.0/spec/filter_set_spec.rb +46 -0
  285. data/capybara-3.40.0/spec/fixtures/capybara.csv +1 -0
  286. data/capybara-3.40.0/spec/fixtures/certificate.pem +25 -0
  287. data/capybara-3.40.0/spec/fixtures/key.pem +27 -0
  288. data/capybara-3.40.0/spec/fixtures/selenium_driver_rspec_failure.rb +13 -0
  289. data/capybara-3.40.0/spec/fixtures/selenium_driver_rspec_success.rb +13 -0
  290. data/capybara-3.40.0/spec/minitest_spec.rb +175 -0
  291. data/capybara-3.40.0/spec/minitest_spec_spec.rb +166 -0
  292. data/capybara-3.40.0/spec/per_session_config_spec.rb +68 -0
  293. data/capybara-3.40.0/spec/rack_test_spec.rb +297 -0
  294. data/capybara-3.40.0/spec/regexp_dissassembler_spec.rb +250 -0
  295. data/capybara-3.40.0/spec/result_spec.rb +202 -0
  296. data/capybara-3.40.0/spec/rspec/features_spec.rb +101 -0
  297. data/capybara-3.40.0/spec/rspec/scenarios_spec.rb +23 -0
  298. data/capybara-3.40.0/spec/rspec/shared_spec_matchers.rb +983 -0
  299. data/capybara-3.40.0/spec/rspec/views_spec.rb +14 -0
  300. data/capybara-3.40.0/spec/rspec_matchers_spec.rb +87 -0
  301. data/capybara-3.40.0/spec/rspec_spec.rb +149 -0
  302. data/capybara-3.40.0/spec/sauce_spec_chrome.rb +43 -0
  303. data/capybara-3.40.0/spec/selector_spec.rb +528 -0
  304. data/capybara-3.40.0/spec/selenium_spec_chrome.rb +209 -0
  305. data/capybara-3.40.0/spec/selenium_spec_chrome_remote.rb +96 -0
  306. data/capybara-3.40.0/spec/selenium_spec_edge.rb +60 -0
  307. data/capybara-3.40.0/spec/selenium_spec_firefox.rb +228 -0
  308. data/capybara-3.40.0/spec/selenium_spec_firefox_remote.rb +94 -0
  309. data/capybara-3.40.0/spec/selenium_spec_ie.rb +149 -0
  310. data/capybara-3.40.0/spec/selenium_spec_safari.rb +162 -0
  311. data/capybara-3.40.0/spec/server_spec.rb +315 -0
  312. data/capybara-3.40.0/spec/session_spec.rb +91 -0
  313. data/capybara-3.40.0/spec/shared_selenium_node.rb +79 -0
  314. data/capybara-3.40.0/spec/shared_selenium_session.rb +566 -0
  315. data/capybara-3.40.0/spec/spec_helper.rb +133 -0
  316. data/capybara-3.40.0/spec/whitespace_normalizer_spec.rb +54 -0
  317. data/capybara-3.40.0/spec/xpath_builder_spec.rb +93 -0
  318. data/mega-max-rb.gemspec +12 -0
  319. metadata +358 -0
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ Capybara::SpecHelper.spec '#find_link' do
4
+ before do
5
+ @session.visit('/with_html')
6
+ end
7
+
8
+ it 'should find any link' do
9
+ expect(@session.find_link('foo').text).to eq('ullamco')
10
+ expect(@session.find_link('labore')[:href]).to match %r{/with_simple_html$}
11
+ end
12
+
13
+ context 'aria_label attribute with Capybara.enable_aria_label' do
14
+ it 'should find when true' do
15
+ Capybara.enable_aria_label = true
16
+ expect(@session.find_link('Go to simple')[:href]).to match %r{/with_simple_html$}
17
+ end
18
+
19
+ it 'should not find when false' do
20
+ Capybara.enable_aria_label = false
21
+ expect { @session.find_link('Go to simple') }.to raise_error(Capybara::ElementNotFound)
22
+ end
23
+ end
24
+
25
+ it 'casts to string' do
26
+ expect(@session.find_link(:foo).text).to eq('ullamco')
27
+ end
28
+
29
+ it "should raise error if the field doesn't exist" do
30
+ expect do
31
+ @session.find_link('Does not exist')
32
+ end.to raise_error(Capybara::ElementNotFound)
33
+ end
34
+
35
+ context 'with :exact option' do
36
+ it 'should accept partial matches when false' do
37
+ expect(@session.find_link('abo', exact: false).text).to eq('labore')
38
+ end
39
+
40
+ it 'should not accept partial matches when true' do
41
+ expect do
42
+ @session.find_link('abo', exact: true)
43
+ end.to raise_error(Capybara::ElementNotFound)
44
+ end
45
+ end
46
+
47
+ context 'without locator' do
48
+ it 'should use options' do
49
+ expect(@session.find_link(href: '#anchor').text).to eq 'Normal Anchor'
50
+ end
51
+ end
52
+
53
+ context 'download filter' do
54
+ it 'finds a download link' do
55
+ expect(@session.find_link('Download Me', download: true).text).to eq 'Download Me'
56
+ end
57
+
58
+ it "doesn't find a download link if download is false" do
59
+ expect { @session.find_link('Download Me', download: false) }.to raise_error Capybara::ElementNotFound
60
+ end
61
+
62
+ it 'finds a renaming download link' do
63
+ expect(@session.find_link(download: 'other.csv').text).to eq 'Download Other'
64
+ end
65
+
66
+ it 'raises if passed an invalid value' do
67
+ expect { @session.find_link(download: 37) }.to raise_error ArgumentError
68
+ end
69
+ end
70
+
71
+ context 'with :target option' do
72
+ it 'should accept partial matches when false' do
73
+ expect(@session.find_link(target: '_self').text).to eq('labore')
74
+ end
75
+
76
+ it 'should not accept partial matches when true' do
77
+ expect { @session.find_link(target: '_blank') }.to raise_error Capybara::ElementNotFound
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,545 @@
1
+ # frozen_string_literal: true
2
+
3
+ Capybara::SpecHelper.spec '#find' do
4
+ before do
5
+ @session.visit('/with_html')
6
+ end
7
+
8
+ after do
9
+ Capybara::Selector.remove(:monkey)
10
+ end
11
+
12
+ it 'should find the first element using the given locator' do
13
+ expect(@session.find('//h1').text).to eq('This is a test')
14
+ expect(@session.find("//input[@id='test_field']").value).to eq('monkey')
15
+ end
16
+
17
+ it 'should find the first element using the given locator and options' do
18
+ expect(@session.find('//a', text: 'Redirect')[:id]).to eq('red')
19
+ expect(@session.find(:css, 'a', text: 'A link came first')[:title]).to eq('twas a fine link')
20
+ end
21
+
22
+ it 'should raise an error if there are multiple matches' do
23
+ expect { @session.find('//a') }.to raise_error(Capybara::Ambiguous)
24
+ end
25
+
26
+ it 'should wait for asynchronous load', requires: [:js] do
27
+ Capybara.default_max_wait_time = 2
28
+ @session.visit('/with_js')
29
+ @session.click_link('Click me')
30
+ expect(@session.find(:css, 'a#has-been-clicked').text).to include('Has been clicked')
31
+ end
32
+
33
+ context 'with :text option' do
34
+ it "casts text's argument to string" do
35
+ expect(@session.find(:css, '.number', text: 42)).to have_content('42')
36
+ end
37
+ end
38
+
39
+ context 'with :wait option', requires: [:js] do
40
+ it 'should not wait for asynchronous load when `false` given' do
41
+ @session.visit('/with_js')
42
+ @session.click_link('Click me')
43
+ expect do
44
+ @session.find(:css, 'a#has-been-clicked', wait: false)
45
+ end.to raise_error(Capybara::ElementNotFound)
46
+ end
47
+
48
+ it 'should not find element if it appears after given wait duration' do
49
+ @session.visit('/with_js')
50
+ @session.click_link('Slowly')
51
+ expect do
52
+ @session.find(:css, 'a#slow-clicked', wait: 0.2)
53
+ end.to raise_error(Capybara::ElementNotFound)
54
+ end
55
+
56
+ it 'should find element if it appears before given wait duration' do
57
+ @session.visit('/with_js')
58
+ @session.click_link('Click me')
59
+ expect(@session.find(:css, 'a#has-been-clicked', wait: 3.0).text).to include('Has been clicked')
60
+ end
61
+ end
62
+
63
+ context 'with frozen time', requires: [:js] do
64
+ if defined?(Process::CLOCK_MONOTONIC)
65
+ it 'will time out even if time is frozen' do
66
+ @session.visit('/with_js')
67
+ now = Time.now
68
+ allow(Time).to receive(:now).and_return(now)
69
+ expect { @session.find('//isnotthere') }.to raise_error(Capybara::ElementNotFound)
70
+ end
71
+ else
72
+ it 'raises an error suggesting that Capybara is stuck in time' do
73
+ @session.visit('/with_js')
74
+ now = Time.now
75
+ allow(Time).to receive(:now).and_return(now)
76
+ expect { @session.find('//isnotthere') }.to raise_error(Capybara::FrozenInTime)
77
+ end
78
+ end
79
+ end
80
+
81
+ context 'with css selectors' do
82
+ it 'should find the first element using the given locator' do
83
+ expect(@session.find(:css, 'h1').text).to eq('This is a test')
84
+ expect(@session.find(:css, "input[id='test_field']").value).to eq('monkey')
85
+ end
86
+
87
+ it 'should support pseudo selectors' do
88
+ expect(@session.find(:css, 'input:disabled').value).to eq('This is disabled')
89
+ end
90
+
91
+ it 'should support escaping characters' do
92
+ expect(@session.find(:css, '#\31 escape\.me').text).to eq('needs escaping')
93
+ expect(@session.find(:css, '.\32 escape').text).to eq('needs escaping')
94
+ end
95
+
96
+ it 'should not warn about locator' do
97
+ expect { @session.find(:css, '#not_on_page') }.to raise_error Capybara::ElementNotFound do |e|
98
+ expect(e.message).not_to match(/you may be passing a CSS selector or XPath expression/)
99
+ end
100
+ end
101
+ end
102
+
103
+ context 'with xpath selectors' do
104
+ it 'should find the first element using the given locator' do
105
+ expect(@session.find(:xpath, '//h1').text).to eq('This is a test')
106
+ expect(@session.find(:xpath, "//input[@id='test_field']").value).to eq('monkey')
107
+ end
108
+
109
+ it 'should warn if passed a non-valid locator type' do
110
+ expect { @session.find(:xpath, 123) }.to raise_error(Exception) # The exact error is not yet well defined
111
+ .and output(/must respond to to_xpath or be an instance of String/).to_stderr
112
+ end
113
+ end
114
+
115
+ context 'with custom selector' do
116
+ it 'should use the custom selector' do
117
+ Capybara.add_selector(:beatle) do
118
+ xpath { |name| ".//*[@id='#{name}']" }
119
+ end
120
+ expect(@session.find(:beatle, 'john').text).to eq('John')
121
+ expect(@session.find(:beatle, 'paul').text).to eq('Paul')
122
+ end
123
+ end
124
+
125
+ context 'with custom selector with custom `match` block' do
126
+ it 'should use the custom selector when locator matches the block' do
127
+ Capybara.add_selector(:beatle) do
128
+ xpath { |num| ".//*[contains(@class, 'beatle')][#{num}]" }
129
+ match { |value| value.is_a?(Integer) }
130
+ end
131
+ expect(@session.find(:beatle, '2').text).to eq('Paul')
132
+ expect(@session.find(1).text).to eq('John')
133
+ expect(@session.find(2).text).to eq('Paul')
134
+ expect(@session.find('//h1').text).to eq('This is a test')
135
+ end
136
+ end
137
+
138
+ context 'with custom selector with custom filter' do
139
+ before do
140
+ Capybara.add_selector(:beatle) do
141
+ xpath { |name| ".//li[contains(@class, 'beatle')][contains(text(), '#{name}')]" }
142
+ node_filter(:type) { |node, type| node[:class].split(/\s+/).include?(type) }
143
+ node_filter(:fail) { |_node, _val| raise Capybara::ElementNotFound, 'fail' }
144
+ end
145
+ end
146
+
147
+ it 'should find elements that match the filter' do
148
+ expect(@session.find(:beatle, 'Paul', type: 'drummer').text).to eq('Paul')
149
+ expect(@session.find(:beatle, 'Ringo', type: 'drummer').text).to eq('Ringo')
150
+ end
151
+
152
+ it 'ignores filter when it is not given' do
153
+ expect(@session.find(:beatle, 'Paul').text).to eq('Paul')
154
+ expect(@session.find(:beatle, 'John').text).to eq('John')
155
+ end
156
+
157
+ it "should not find elements that don't match the filter" do
158
+ expect { @session.find(:beatle, 'John', type: 'drummer') }.to raise_error(Capybara::ElementNotFound)
159
+ expect { @session.find(:beatle, 'George', type: 'drummer') }.to raise_error(Capybara::ElementNotFound)
160
+ end
161
+
162
+ it 'should not raise an ElementNotFound error from in a filter' do
163
+ expect { @session.find(:beatle, 'John', fail: 'something') }.to raise_error(Capybara::ElementNotFound, /beatle "John"/)
164
+ end
165
+ end
166
+
167
+ context 'with custom selector with custom filter and default' do
168
+ before do
169
+ Capybara.add_selector(:beatle) do
170
+ xpath { |name| ".//li[contains(@class, 'beatle')][contains(text(), '#{name}')]" }
171
+ node_filter(:type, default: 'drummer') { |node, type| node[:class].split(/\s+/).include?(type) }
172
+ end
173
+ end
174
+
175
+ it 'should find elements that match the filter' do
176
+ expect(@session.find(:beatle, 'Paul', type: 'drummer').text).to eq('Paul')
177
+ expect(@session.find(:beatle, 'Ringo', type: 'drummer').text).to eq('Ringo')
178
+ end
179
+
180
+ it 'should use default value when filter is not given' do
181
+ expect(@session.find(:beatle, 'Paul').text).to eq('Paul')
182
+ expect { @session.find(:beatle, 'John') }.to raise_error(Capybara::ElementNotFound)
183
+ end
184
+
185
+ it "should not find elements that don't match the filter" do
186
+ expect { @session.find(:beatle, 'John', type: 'drummer') }.to raise_error(Capybara::ElementNotFound)
187
+ expect { @session.find(:beatle, 'George', type: 'drummer') }.to raise_error(Capybara::ElementNotFound)
188
+ end
189
+ end
190
+
191
+ context 'with alternate filter set' do
192
+ before do
193
+ Capybara::Selector::FilterSet.add(:value) do
194
+ node_filter(:with) { |node, with| node.value == with.to_s }
195
+ end
196
+
197
+ Capybara.add_selector(:id_with_field_filters) do
198
+ xpath { |id| XPath.descendant[XPath.attr(:id) == id.to_s] }
199
+ filter_set(:field)
200
+ end
201
+ end
202
+
203
+ it 'should allow use of filters from custom filter set' do
204
+ expect(@session.find(:id, 'test_field', filter_set: :value, with: 'monkey').value).to eq('monkey')
205
+ expect { @session.find(:id, 'test_field', filter_set: :value, with: 'not_monkey') }.to raise_error(Capybara::ElementNotFound)
206
+ end
207
+
208
+ it 'should allow use of filter set from a different selector' do
209
+ expect(@session.find(:id, 'test_field', filter_set: :field, with: 'monkey').value).to eq('monkey')
210
+ expect { @session.find(:id, 'test_field', filter_set: :field, with: 'not_monkey') }.to raise_error(Capybara::ElementNotFound)
211
+ end
212
+
213
+ it 'should allow importing of filter set into selector' do
214
+ expect(@session.find(:id_with_field_filters, 'test_field', with: 'monkey').value).to eq('monkey')
215
+ expect { @session.find(:id_with_field_filters, 'test_field', with: 'not_monkey') }.to raise_error(Capybara::ElementNotFound)
216
+ end
217
+ end
218
+
219
+ context 'with css as default selector' do
220
+ before { Capybara.default_selector = :css }
221
+
222
+ after { Capybara.default_selector = :xpath }
223
+
224
+ it 'should find the first element using the given locator' do
225
+ expect(@session.find('h1').text).to eq('This is a test')
226
+ expect(@session.find("input[id='test_field']").value).to eq('monkey')
227
+ end
228
+ end
229
+
230
+ it 'should raise ElementNotFound with a useful default message if nothing was found' do
231
+ expect do
232
+ @session.find(:xpath, '//div[@id="nosuchthing"]').to be_nil
233
+ end.to raise_error(Capybara::ElementNotFound, 'Unable to find xpath "//div[@id=\\"nosuchthing\\"]"')
234
+ end
235
+
236
+ context 'without locator' do
237
+ it 'should not output `nil` in the ElementNotFound message if nothing was found' do
238
+ expect do
239
+ @session.find(:label, text: 'no such thing').to be_nil
240
+ end.to raise_error(Capybara::ElementNotFound, 'Unable to find label')
241
+ end
242
+ end
243
+
244
+ it 'should accept an XPath instance' do
245
+ @session.visit('/form')
246
+ @xpath = Capybara::Selector.new(:fillable_field, config: {}, format: :xpath).call('First Name')
247
+ expect(@xpath).to be_a(XPath::Union)
248
+ expect(@session.find(@xpath).value).to eq('John')
249
+ end
250
+
251
+ context 'with :exact option' do
252
+ it 'matches exactly when true' do
253
+ expect(@session.find(:xpath, XPath.descendant(:input)[XPath.attr(:id).is('test_field')], exact: true).value).to eq('monkey')
254
+ expect do
255
+ @session.find(:xpath, XPath.descendant(:input)[XPath.attr(:id).is('est_fiel')], exact: true)
256
+ end.to raise_error(Capybara::ElementNotFound)
257
+ end
258
+
259
+ it 'matches loosely when false' do
260
+ expect(@session.find(:xpath, XPath.descendant(:input)[XPath.attr(:id).is('test_field')], exact: false).value).to eq('monkey')
261
+ expect(@session.find(:xpath, XPath.descendant(:input)[XPath.attr(:id).is('est_fiel')], exact: false).value).to eq('monkey')
262
+ end
263
+
264
+ it 'defaults to `Capybara.exact`' do
265
+ Capybara.exact = true
266
+ expect do
267
+ @session.find(:xpath, XPath.descendant(:input)[XPath.attr(:id).is('est_fiel')])
268
+ end.to raise_error(Capybara::ElementNotFound)
269
+ Capybara.exact = false
270
+ @session.find(:xpath, XPath.descendant(:input)[XPath.attr(:id).is('est_fiel')])
271
+ end
272
+
273
+ it 'warns when the option has no effect' do
274
+ expect { @session.find(:css, '#test_field', exact: true) }.to \
275
+ output(/^The :exact option only has an effect on queries using the XPath#is method. Using it with the query "#test_field" has no effect/).to_stderr
276
+ end
277
+ end
278
+
279
+ context 'with :match option' do
280
+ context 'when set to `one`' do
281
+ it 'raises an error when multiple matches exist' do
282
+ expect do
283
+ @session.find(:css, '.multiple', match: :one)
284
+ end.to raise_error(Capybara::Ambiguous)
285
+ end
286
+
287
+ it 'raises an error even if there the match is exact and the others are inexact' do
288
+ expect do
289
+ @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular')], exact: false, match: :one)
290
+ end.to raise_error(Capybara::Ambiguous)
291
+ end
292
+
293
+ it 'returns the element if there is only one' do
294
+ expect(@session.find(:css, '.singular', match: :one).text).to eq('singular')
295
+ end
296
+
297
+ it 'raises an error if there is no match' do
298
+ expect do
299
+ @session.find(:css, '.does-not-exist', match: :one)
300
+ end.to raise_error(Capybara::ElementNotFound)
301
+ end
302
+ end
303
+
304
+ context 'when set to `first`' do
305
+ it 'returns the first matched element' do
306
+ expect(@session.find(:css, '.multiple', match: :first).text).to eq('multiple one')
307
+ end
308
+
309
+ it 'raises an error if there is no match' do
310
+ expect do
311
+ @session.find(:css, '.does-not-exist', match: :first)
312
+ end.to raise_error(Capybara::ElementNotFound)
313
+ end
314
+ end
315
+
316
+ context 'when set to `smart`' do
317
+ context 'and `exact` set to `false`' do
318
+ it 'raises an error when there are multiple exact matches' do
319
+ expect do
320
+ @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('multiple')], match: :smart, exact: false)
321
+ end.to raise_error(Capybara::Ambiguous)
322
+ end
323
+
324
+ it 'finds a single exact match when there also are inexact matches' do
325
+ result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular')], match: :smart, exact: false)
326
+ expect(result.text).to eq('almost singular')
327
+ end
328
+
329
+ it 'raises an error when there are multiple inexact matches' do
330
+ expect do
331
+ @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singul')], match: :smart, exact: false)
332
+ end.to raise_error(Capybara::Ambiguous)
333
+ end
334
+
335
+ it 'finds a single inexact match' do
336
+ result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular but')], match: :smart, exact: false)
337
+ expect(result.text).to eq('almost singular but not quite')
338
+ end
339
+
340
+ it 'raises an error if there is no match' do
341
+ expect do
342
+ @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('does-not-exist')], match: :smart, exact: false)
343
+ end.to raise_error(Capybara::ElementNotFound)
344
+ end
345
+ end
346
+
347
+ context 'with `exact` set to `true`' do
348
+ it 'raises an error when there are multiple exact matches' do
349
+ expect do
350
+ @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('multiple')], match: :smart, exact: true)
351
+ end.to raise_error(Capybara::Ambiguous)
352
+ end
353
+
354
+ it 'finds a single exact match when there also are inexact matches' do
355
+ result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular')], match: :smart, exact: true)
356
+ expect(result.text).to eq('almost singular')
357
+ end
358
+
359
+ it 'raises an error when there are multiple inexact matches' do
360
+ expect do
361
+ @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singul')], match: :smart, exact: true)
362
+ end.to raise_error(Capybara::ElementNotFound)
363
+ end
364
+
365
+ it 'raises an error when there is a single inexact matches' do
366
+ expect do
367
+ @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular but')], match: :smart, exact: true)
368
+ end.to raise_error(Capybara::ElementNotFound)
369
+ end
370
+
371
+ it 'raises an error if there is no match' do
372
+ expect do
373
+ @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('does-not-exist')], match: :smart, exact: true)
374
+ end.to raise_error(Capybara::ElementNotFound)
375
+ end
376
+ end
377
+ end
378
+
379
+ context 'when set to `prefer_exact`' do
380
+ context 'and `exact` set to `false`' do
381
+ it 'picks the first one when there are multiple exact matches' do
382
+ result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('multiple')], match: :prefer_exact, exact: false)
383
+ expect(result.text).to eq('multiple one')
384
+ end
385
+
386
+ it 'finds a single exact match when there also are inexact matches' do
387
+ result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular')], match: :prefer_exact, exact: false)
388
+ expect(result.text).to eq('almost singular')
389
+ end
390
+
391
+ it 'picks the first one when there are multiple inexact matches' do
392
+ result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singul')], match: :prefer_exact, exact: false)
393
+ expect(result.text).to eq('almost singular but not quite')
394
+ end
395
+
396
+ it 'finds a single inexact match' do
397
+ result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular but')], match: :prefer_exact, exact: false)
398
+ expect(result.text).to eq('almost singular but not quite')
399
+ end
400
+
401
+ it 'raises an error if there is no match' do
402
+ expect do
403
+ @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('does-not-exist')], match: :prefer_exact, exact: false)
404
+ end.to raise_error(Capybara::ElementNotFound)
405
+ end
406
+ end
407
+
408
+ context 'with `exact` set to `true`' do
409
+ it 'picks the first one when there are multiple exact matches' do
410
+ result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('multiple')], match: :prefer_exact, exact: true)
411
+ expect(result.text).to eq('multiple one')
412
+ end
413
+
414
+ it 'finds a single exact match when there also are inexact matches' do
415
+ result = @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular')], match: :prefer_exact, exact: true)
416
+ expect(result.text).to eq('almost singular')
417
+ end
418
+
419
+ it 'raises an error if there are multiple inexact matches' do
420
+ expect do
421
+ @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singul')], match: :prefer_exact, exact: true)
422
+ end.to raise_error(Capybara::ElementNotFound)
423
+ end
424
+
425
+ it 'raises an error if there is a single inexact match' do
426
+ expect do
427
+ @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('almost_singular but')], match: :prefer_exact, exact: true)
428
+ end.to raise_error(Capybara::ElementNotFound)
429
+ end
430
+
431
+ it 'raises an error if there is no match' do
432
+ expect do
433
+ @session.find(:xpath, XPath.descendant[XPath.attr(:class).is('does-not-exist')], match: :prefer_exact, exact: true)
434
+ end.to raise_error(Capybara::ElementNotFound)
435
+ end
436
+ end
437
+ end
438
+
439
+ it 'defaults to `Capybara.match`' do
440
+ Capybara.match = :one
441
+ expect do
442
+ @session.find(:css, '.multiple')
443
+ end.to raise_error(Capybara::Ambiguous)
444
+ Capybara.match = :first
445
+ expect(@session.find(:css, '.multiple').text).to eq('multiple one')
446
+ end
447
+
448
+ it 'raises an error when unknown option given' do
449
+ expect do
450
+ @session.find(:css, '.singular', match: :schmoo)
451
+ end.to raise_error(ArgumentError)
452
+ end
453
+ end
454
+
455
+ it 'supports a custom filter block' do
456
+ expect(@session.find(:css, 'input', &:disabled?)[:name]).to eq('disabled_text')
457
+ end
458
+
459
+ context 'with spatial filters', requires: [:spatial] do
460
+ before do
461
+ @session.visit('/spatial')
462
+ end
463
+
464
+ let :center do
465
+ @session.find(:css, 'div.center')
466
+ end
467
+
468
+ it 'should find an element above another element' do
469
+ expect(@session.find(:css, 'div:not(.corner)', above: center).text).to eq('2')
470
+ end
471
+
472
+ it 'should find an element below another element' do
473
+ expect(@session.find(:css, 'div:not(.corner):not(.footer)', below: center).text).to eq('8')
474
+ end
475
+
476
+ it 'should find an element left of another element' do
477
+ expect(@session.find(:css, 'div:not(.corner)', left_of: center).text).to eq('4')
478
+ end
479
+
480
+ it 'should find an element right of another element' do
481
+ expect(@session.find(:css, 'div:not(.corner)', right_of: center).text).to eq('6')
482
+ end
483
+
484
+ it 'should combine spatial filters' do
485
+ expect(@session.find(:css, 'div', left_of: center, above: center).text).to eq('1')
486
+ expect(@session.find(:css, 'div', right_of: center, below: center).text).to eq('9')
487
+ end
488
+
489
+ it 'should find an element "near" another element' do
490
+ expect(@session.find(:css, 'div.distance', near: center).text).to eq('2')
491
+ end
492
+ end
493
+
494
+ context 'within a scope' do
495
+ before do
496
+ @session.visit('/with_scope')
497
+ end
498
+
499
+ it 'should find the an element using the given locator' do
500
+ @session.within(:xpath, "//div[@id='for_bar']") do
501
+ expect(@session.find('.//li[1]').text).to match(/With Simple HTML/)
502
+ end
503
+ end
504
+
505
+ it 'should support pseudo selectors' do
506
+ @session.within(:xpath, "//div[@id='for_bar']") do
507
+ expect(@session.find(:css, 'input:disabled').value).to eq('James')
508
+ end
509
+ end
510
+ end
511
+
512
+ it 'should raise if selector type is unknown' do
513
+ expect do
514
+ @session.find(:unknown, '//h1')
515
+ end.to raise_error(ArgumentError)
516
+ end
517
+
518
+ context 'with Capybara.test_id' do
519
+ it 'should not match on it when nil' do
520
+ Capybara.test_id = nil
521
+ expect(@session).not_to have_field('test_id')
522
+ end
523
+
524
+ it 'should work with the attribute set to `data-test-id` attribute' do
525
+ Capybara.test_id = 'data-test-id'
526
+ expect(@session.find(:field, 'test_id')[:id]).to eq 'test_field'
527
+ end
528
+
529
+ it 'should use a different attribute if set' do
530
+ Capybara.test_id = 'data-other-test-id'
531
+ expect(@session.find(:field, 'test_id')[:id]).to eq 'normal'
532
+ end
533
+
534
+ it 'should find a link with the test_id' do
535
+ Capybara.test_id = 'data-test-id'
536
+ expect(@session.find(:link, 'test-foo')[:id]).to eq 'foo'
537
+ end
538
+ end
539
+
540
+ it 'should warn if passed count options' do
541
+ allow(Capybara::Helpers).to receive(:warn)
542
+ @session.find('//h1', count: 44)
543
+ expect(Capybara::Helpers).to have_received(:warn).with(/'find' does not support count options/)
544
+ end
545
+ end