capybara 3.29.0 → 3.37.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +229 -15
  3. data/README.md +13 -4
  4. data/lib/capybara/config.rb +24 -10
  5. data/lib/capybara/cucumber.rb +1 -1
  6. data/lib/capybara/driver/base.rb +8 -0
  7. data/lib/capybara/driver/node.rb +5 -1
  8. data/lib/capybara/dsl.rb +5 -3
  9. data/lib/capybara/helpers.rb +19 -2
  10. data/lib/capybara/minitest/spec.rb +156 -97
  11. data/lib/capybara/minitest.rb +232 -144
  12. data/lib/capybara/node/actions.rb +41 -37
  13. data/lib/capybara/node/base.rb +6 -6
  14. data/lib/capybara/node/document.rb +2 -2
  15. data/lib/capybara/node/document_matchers.rb +3 -3
  16. data/lib/capybara/node/element.rb +35 -21
  17. data/lib/capybara/node/finders.rb +33 -19
  18. data/lib/capybara/node/matchers.rb +72 -57
  19. data/lib/capybara/node/simple.rb +13 -3
  20. data/lib/capybara/queries/active_element_query.rb +18 -0
  21. data/lib/capybara/queries/ancestor_query.rb +4 -3
  22. data/lib/capybara/queries/base_query.rb +2 -1
  23. data/lib/capybara/queries/current_path_query.rb +14 -4
  24. data/lib/capybara/queries/selector_query.rb +91 -30
  25. data/lib/capybara/queries/sibling_query.rb +4 -3
  26. data/lib/capybara/queries/style_query.rb +1 -1
  27. data/lib/capybara/queries/text_query.rb +7 -1
  28. data/lib/capybara/rack_test/browser.rb +68 -10
  29. data/lib/capybara/rack_test/driver.rb +6 -5
  30. data/lib/capybara/rack_test/form.rb +2 -2
  31. data/lib/capybara/rack_test/node.rb +44 -16
  32. data/lib/capybara/registration_container.rb +41 -0
  33. data/lib/capybara/registrations/drivers.rb +18 -12
  34. data/lib/capybara/registrations/patches/puma_ssl.rb +3 -1
  35. data/lib/capybara/registrations/servers.rb +3 -2
  36. data/lib/capybara/result.rb +35 -15
  37. data/lib/capybara/rspec/matcher_proxies.rb +8 -8
  38. data/lib/capybara/rspec/matchers/base.rb +12 -6
  39. data/lib/capybara/rspec/matchers/count_sugar.rb +2 -1
  40. data/lib/capybara/rspec/matchers/have_ancestor.rb +4 -3
  41. data/lib/capybara/rspec/matchers/have_current_path.rb +2 -2
  42. data/lib/capybara/rspec/matchers/have_selector.rb +16 -8
  43. data/lib/capybara/rspec/matchers/have_sibling.rb +3 -3
  44. data/lib/capybara/rspec/matchers/have_text.rb +3 -3
  45. data/lib/capybara/rspec/matchers/have_title.rb +2 -2
  46. data/lib/capybara/rspec/matchers/match_selector.rb +3 -3
  47. data/lib/capybara/rspec/matchers/match_style.rb +7 -2
  48. data/lib/capybara/rspec/matchers/spatial_sugar.rb +2 -1
  49. data/lib/capybara/rspec/matchers.rb +33 -32
  50. data/lib/capybara/rspec.rb +2 -0
  51. data/lib/capybara/selector/builders/css_builder.rb +2 -2
  52. data/lib/capybara/selector/builders/xpath_builder.rb +4 -2
  53. data/lib/capybara/selector/css.rb +2 -2
  54. data/lib/capybara/selector/definition/button.rb +35 -13
  55. data/lib/capybara/selector/definition/checkbox.rb +3 -3
  56. data/lib/capybara/selector/definition/css.rb +3 -1
  57. data/lib/capybara/selector/definition/datalist_input.rb +2 -2
  58. data/lib/capybara/selector/definition/datalist_option.rb +1 -1
  59. data/lib/capybara/selector/definition/element.rb +3 -2
  60. data/lib/capybara/selector/definition/field.rb +1 -1
  61. data/lib/capybara/selector/definition/file_field.rb +2 -2
  62. data/lib/capybara/selector/definition/fillable_field.rb +3 -3
  63. data/lib/capybara/selector/definition/label.rb +5 -3
  64. data/lib/capybara/selector/definition/link.rb +8 -0
  65. data/lib/capybara/selector/definition/radio_button.rb +3 -3
  66. data/lib/capybara/selector/definition/select.rb +33 -14
  67. data/lib/capybara/selector/definition/table.rb +6 -3
  68. data/lib/capybara/selector/definition/table_row.rb +2 -2
  69. data/lib/capybara/selector/definition.rb +15 -11
  70. data/lib/capybara/selector/filter_set.rb +17 -17
  71. data/lib/capybara/selector/filters/base.rb +6 -1
  72. data/lib/capybara/selector/filters/locator_filter.rb +1 -1
  73. data/lib/capybara/selector/selector.rb +17 -3
  74. data/lib/capybara/selector.rb +37 -19
  75. data/lib/capybara/selenium/atoms/getAttribute.min.js +1 -1
  76. data/lib/capybara/selenium/atoms/src/getAttribute.js +1 -1
  77. data/lib/capybara/selenium/atoms/src/isDisplayed.js +1 -1
  78. data/lib/capybara/selenium/driver.rb +84 -17
  79. data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +11 -13
  80. data/lib/capybara/selenium/driver_specializations/edge_driver.rb +10 -12
  81. data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +4 -4
  82. data/lib/capybara/selenium/extensions/find.rb +4 -4
  83. data/lib/capybara/selenium/extensions/html5_drag.rb +30 -13
  84. data/lib/capybara/selenium/extensions/scroll.rb +8 -10
  85. data/lib/capybara/selenium/logger_suppressor.rb +8 -2
  86. data/lib/capybara/selenium/node.rb +122 -26
  87. data/lib/capybara/selenium/nodes/chrome_node.rb +34 -19
  88. data/lib/capybara/selenium/nodes/edge_node.rb +5 -3
  89. data/lib/capybara/selenium/nodes/firefox_node.rb +11 -6
  90. data/lib/capybara/selenium/nodes/safari_node.rb +3 -3
  91. data/lib/capybara/selenium/patches/action_pauser.rb +26 -0
  92. data/lib/capybara/selenium/patches/atoms.rb +4 -4
  93. data/lib/capybara/selenium/patches/logs.rb +7 -9
  94. data/lib/capybara/server/animation_disabler.rb +38 -15
  95. data/lib/capybara/server/checker.rb +1 -1
  96. data/lib/capybara/server/middleware.rb +22 -10
  97. data/lib/capybara/server.rb +15 -3
  98. data/lib/capybara/session/config.rb +10 -4
  99. data/lib/capybara/session/matchers.rb +11 -11
  100. data/lib/capybara/session.rb +62 -39
  101. data/lib/capybara/spec/public/test.js +75 -7
  102. data/lib/capybara/spec/session/accept_alert_spec.rb +1 -1
  103. data/lib/capybara/spec/session/active_element_spec.rb +31 -0
  104. data/lib/capybara/spec/session/all_spec.rb +63 -12
  105. data/lib/capybara/spec/session/ancestor_spec.rb +5 -0
  106. data/lib/capybara/spec/session/assert_text_spec.rb +26 -22
  107. data/lib/capybara/spec/session/check_spec.rb +15 -0
  108. data/lib/capybara/spec/session/choose_spec.rb +6 -0
  109. data/lib/capybara/spec/session/click_button_spec.rb +16 -0
  110. data/lib/capybara/spec/session/click_link_or_button_spec.rb +9 -0
  111. data/lib/capybara/spec/session/current_url_spec.rb +11 -1
  112. data/lib/capybara/spec/session/fill_in_spec.rb +29 -0
  113. data/lib/capybara/spec/session/find_spec.rb +37 -8
  114. data/lib/capybara/spec/session/has_any_selectors_spec.rb +4 -0
  115. data/lib/capybara/spec/session/has_button_spec.rb +75 -0
  116. data/lib/capybara/spec/session/has_css_spec.rb +14 -10
  117. data/lib/capybara/spec/session/has_current_path_spec.rb +17 -4
  118. data/lib/capybara/spec/session/has_field_spec.rb +41 -1
  119. data/lib/capybara/spec/session/has_link_spec.rb +30 -0
  120. data/lib/capybara/spec/session/has_select_spec.rb +36 -8
  121. data/lib/capybara/spec/session/has_selector_spec.rb +19 -4
  122. data/lib/capybara/spec/session/has_table_spec.rb +51 -5
  123. data/lib/capybara/spec/session/has_text_spec.rb +21 -1
  124. data/lib/capybara/spec/session/html_spec.rb +1 -1
  125. data/lib/capybara/spec/session/matches_style_spec.rb +2 -2
  126. data/lib/capybara/spec/session/node_spec.rb +226 -33
  127. data/lib/capybara/spec/session/refresh_spec.rb +2 -1
  128. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +2 -2
  129. data/lib/capybara/spec/session/save_page_spec.rb +4 -4
  130. data/lib/capybara/spec/session/save_screenshot_spec.rb +4 -4
  131. data/lib/capybara/spec/session/scroll_spec.rb +4 -4
  132. data/lib/capybara/spec/session/selectors_spec.rb +15 -2
  133. data/lib/capybara/spec/session/visit_spec.rb +20 -0
  134. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +1 -1
  135. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +1 -1
  136. data/lib/capybara/spec/session/window/window_spec.rb +9 -9
  137. data/lib/capybara/spec/session/window/windows_spec.rb +1 -1
  138. data/lib/capybara/spec/spec_helper.rb +17 -17
  139. data/lib/capybara/spec/test_app.rb +89 -29
  140. data/lib/capybara/spec/views/animated.erb +1 -1
  141. data/lib/capybara/spec/views/form.erb +52 -6
  142. data/lib/capybara/spec/views/frame_child.erb +1 -1
  143. data/lib/capybara/spec/views/frame_one.erb +1 -1
  144. data/lib/capybara/spec/views/frame_parent.erb +1 -1
  145. data/lib/capybara/spec/views/frame_two.erb +1 -1
  146. data/lib/capybara/spec/views/initial_alert.erb +2 -1
  147. data/lib/capybara/spec/views/layout.erb +10 -0
  148. data/lib/capybara/spec/views/obscured.erb +1 -1
  149. data/lib/capybara/spec/views/offset.erb +2 -1
  150. data/lib/capybara/spec/views/path.erb +2 -2
  151. data/lib/capybara/spec/views/popup_one.erb +1 -1
  152. data/lib/capybara/spec/views/popup_two.erb +1 -1
  153. data/lib/capybara/spec/views/react.erb +2 -2
  154. data/lib/capybara/spec/views/scroll.erb +2 -1
  155. data/lib/capybara/spec/views/spatial.erb +1 -1
  156. data/lib/capybara/spec/views/with_animation.erb +10 -3
  157. data/lib/capybara/spec/views/with_base_tag.erb +2 -2
  158. data/lib/capybara/spec/views/with_dragula.erb +5 -3
  159. data/lib/capybara/spec/views/with_fixed_header_footer.erb +2 -1
  160. data/lib/capybara/spec/views/with_hover.erb +2 -2
  161. data/lib/capybara/spec/views/with_html.erb +3 -3
  162. data/lib/capybara/spec/views/with_jquery_animation.erb +24 -0
  163. data/lib/capybara/spec/views/with_js.erb +5 -3
  164. data/lib/capybara/spec/views/with_jstree.erb +1 -1
  165. data/lib/capybara/spec/views/with_namespace.erb +1 -0
  166. data/lib/capybara/spec/views/with_shadow.erb +31 -0
  167. data/lib/capybara/spec/views/with_slow_unload.erb +2 -1
  168. data/lib/capybara/spec/views/with_sortable_js.erb +3 -3
  169. data/lib/capybara/spec/views/with_unload_alert.erb +1 -0
  170. data/lib/capybara/spec/views/with_windows.erb +1 -1
  171. data/lib/capybara/spec/views/within_frames.erb +1 -1
  172. data/lib/capybara/version.rb +1 -1
  173. data/lib/capybara/window.rb +4 -8
  174. data/lib/capybara.rb +36 -29
  175. data/spec/basic_node_spec.rb +25 -11
  176. data/spec/capybara_spec.rb +1 -1
  177. data/spec/dsl_spec.rb +18 -5
  178. data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -2
  179. data/spec/fixtures/selenium_driver_rspec_success.rb +3 -3
  180. data/spec/minitest_spec.rb +3 -2
  181. data/spec/minitest_spec_spec.rb +46 -46
  182. data/spec/rack_test_spec.rb +43 -11
  183. data/spec/regexp_dissassembler_spec.rb +40 -36
  184. data/spec/result_spec.rb +53 -45
  185. data/spec/rspec/features_spec.rb +7 -4
  186. data/spec/rspec/scenarios_spec.rb +5 -1
  187. data/spec/rspec/shared_spec_matchers.rb +68 -56
  188. data/spec/rspec_spec.rb +8 -4
  189. data/spec/sauce_spec_chrome.rb +3 -3
  190. data/spec/selector_spec.rb +19 -4
  191. data/spec/selenium_spec_chrome.rb +49 -26
  192. data/spec/selenium_spec_chrome_remote.rb +13 -6
  193. data/spec/selenium_spec_firefox.rb +29 -17
  194. data/spec/selenium_spec_firefox_remote.rb +2 -2
  195. data/spec/selenium_spec_ie.rb +3 -6
  196. data/spec/selenium_spec_safari.rb +31 -19
  197. data/spec/server_spec.rb +88 -35
  198. data/spec/session_spec.rb +1 -1
  199. data/spec/shared_selenium_node.rb +21 -7
  200. data/spec/shared_selenium_session.rb +123 -21
  201. data/spec/spec_helper.rb +2 -2
  202. metadata +80 -21
  203. data/lib/capybara/spec/session/source_spec.rb +0 -0
  204. data/lib/capybara/spec/views/with_title.erb +0 -5
@@ -5,192 +5,251 @@ require 'minitest/spec'
5
5
  module Capybara
6
6
  module Minitest
7
7
  module Expectations
8
- %w[text content title current_path].each do |assertion|
9
- infect_an_assertion "assert_#{assertion}", "must_have_#{assertion}", :reverse
10
- infect_an_assertion "refute_#{assertion}", "wont_have_#{assertion}", :reverse
11
- end
8
+ ##
9
+ # Expectation that there is an ancestor
10
+ #
11
+ # @!method must_have_ancestor
12
+ # See {Capybara::Node::Matchers#has_ancestor?}
12
13
 
13
- # rubocop:disable Style/MultilineBlockChain
14
- (%w[selector xpath css link button field select table checked_field unchecked_field
15
- ancestor sibling].flat_map do |assertion|
16
- [%W[assert_#{assertion} must_have_#{assertion}],
17
- %W[refute_#{assertion} wont_have_#{assertion}]]
18
- end + [%w[assert_all_of_selectors must_have_all_of_selectors],
19
- %w[assert_none_of_selectors must_have_none_of_selectors],
20
- %w[assert_any_of_selectors must_have_any_of_selectors],
21
- %w[assert_matches_style must_match_style]] +
22
- %w[selector xpath css].flat_map do |assertion|
23
- [%W[assert_matches_#{assertion} must_match_#{assertion}],
24
- %W[refute_matches_#{assertion} wont_match_#{assertion}]]
25
- end).each do |(meth, new_name)|
26
- class_eval <<-ASSERTION, __FILE__, __LINE__ + 1
27
- def #{new_name} *args, &block
28
- ::Minitest::Expectation.new(self, ::Minitest::Spec.current).#{new_name}(*args, &block)
29
- end
30
- ASSERTION
14
+ ##
15
+ # Expectation that there is button
16
+ #
17
+ # @!method must_have_button
18
+ # See {Capybara::Node::Matchers#has_button?}
31
19
 
32
- ::Minitest::Expectation.class_eval <<-ASSERTION, __FILE__, __LINE__ + 1
33
- def #{new_name} *args, &block
34
- ctx.#{meth}(target, *args, &block)
35
- end
36
- ASSERTION
37
- end
38
- # rubocop:enable Style/MultilineBlockChain
20
+ ##
21
+ # Expectation that there is no button
22
+ #
23
+ # @!method wont_have_button
24
+ # See {Capybara::Node::Matchers#has_no_button?}
39
25
 
40
26
  ##
41
- # @deprecated
42
- def must_have_style(*args, &block)
43
- warn 'must_have_style is deprecated, please use must_match_style'
44
- must_match_style(*args, &block)
45
- end
27
+ # Expectation that there is checked_field
28
+ #
29
+ # @!method must_have_checked_field
30
+ # See {Capybara::Node::Matchers#has_checked_field?}
46
31
 
47
32
  ##
48
- # Expectation that there is xpath
33
+ # Expectation that there is no checked_field
49
34
  #
50
- # @!method must_have_xpath
51
- # see Capybara::Node::Matchers#has_xpath?
35
+ # @!method wont_have_checked_field
36
+ # See {Capybara::Node::Matchers#has_no_checked_field?}
52
37
 
53
38
  ##
54
- # Expectation that there is no xpath
39
+ # Expectation that there is unchecked_field
55
40
  #
56
- # @!method wont_have_xpath
57
- # see Capybara::Node::Matchers#has_no_xpath?
41
+ # @!method must_have_unchecked_field
42
+ # See {Capybara::Node::Matchers#has_unchecked_field?}
58
43
 
59
44
  ##
60
- # Expectation that there is css
45
+ # Expectation that there is no unchecked_field
61
46
  #
62
- # @!method must_have_css
63
- # see Capybara::Node::Matchers#has_css?
47
+ # @!method wont_have_unchecked_field
48
+ # See {Capybara::Node::Matchers#has_no_unchecked_field?}
64
49
 
65
50
  ##
66
- # Expectation that there is no css
51
+ # Expectation that page content does match
67
52
  #
68
- # @!method wont_have_css
69
- # see Capybara::Node::Matchers#has_no_css?
53
+ # @!method must_have_content
54
+ # See {Capybara::Node::Matchers#has_content?}
70
55
 
71
56
  ##
72
- # Expectation that there is link
57
+ # Expectation that page content does not match
73
58
  #
74
- # @!method must_have_link
75
- # see {Capybara::Node::Matchers#has_link?}
59
+ # @!method wont_have_content
60
+ # See {Capybara::Node::Matchers#has_no_content?}
76
61
 
77
62
  ##
78
- # Expectation that there is no link
63
+ # Expectation that there is css
79
64
  #
80
- # @!method wont_have_link
81
- # see {Capybara::Node::Matchers#has_no_link?}
65
+ # @!method must_have_css
66
+ # See {Capybara::Node::Matchers#has_css?}
82
67
 
83
68
  ##
84
- # Expectation that there is button
69
+ # Expectation that there is no css
85
70
  #
86
- # @!method must_have_button
87
- # see {Capybara::Node::Matchers#has_button?}
71
+ # @!method wont_have_css
72
+ # See {Capybara::Node::Matchers#has_no_css?}
88
73
 
89
74
  ##
90
- # Expectation that there is no button
75
+ # Expectation that current path matches
91
76
  #
92
- # @!method wont_have_button
93
- # see {Capybara::Node::Matchers#has_no_button?}
77
+ # @!method must_have_current_path
78
+ # See {Capybara::SessionMatchers#has_current_path?}
79
+
80
+ ##
81
+ # Expectation that current page does not match
82
+ #
83
+ # @!method wont_have_current_path
84
+ # See {Capybara::SessionMatchers#has_no_current_path?}
94
85
 
95
86
  ##
96
87
  # Expectation that there is field
97
88
  #
98
89
  # @!method must_have_field
99
- # see {Capybara::Node::Matchers#has_field?}
90
+ # See {Capybara::Node::Matchers#has_field?}
100
91
 
101
92
  ##
102
93
  # Expectation that there is no field
103
94
  #
104
95
  # @!method wont_have_field
105
- # see {Capybara::Node::Matchers#has_no_field?}
96
+ # See {Capybara::Node::Matchers#has_no_field?}
106
97
 
107
98
  ##
108
- # Expectation that there is checked_field
99
+ # Expectation that there is link
109
100
  #
110
- # @!method must_have_checked_field
111
- # see {Capybara::Node::Matchers#has_checked_field?}
101
+ # @!method must_have_link
102
+ # See {Capybara::Node::Matchers#has_link?}
112
103
 
113
104
  ##
114
- # Expectation that there is no checked_field
105
+ # Expectation that there is no link
115
106
  #
116
- # @!method wont_have_chceked_field
107
+ # @!method wont_have_link
108
+ # See {Capybara::Node::Matchers#has_no_link?}
117
109
 
118
110
  ##
119
- # Expectation that there is unchecked_field
111
+ # Expectation that page text does match
120
112
  #
121
- # @!method must_have_unchecked_field
122
- # see {Capybara::Node::Matchers#has_unchecked_field?}
113
+ # @!method must_have_text
114
+ # See {Capybara::Node::Matchers#has_text?}
123
115
 
124
116
  ##
125
- # Expectation that there is no unchecked_field
117
+ # Expectation that page text does not match
126
118
  #
127
- # @!method wont_have_unchceked_field
119
+ # @!method wont_have_text
120
+ # See {Capybara::Node::Matchers#has_no_text?}
121
+
122
+ ##
123
+ # Expectation that page title does match
124
+ #
125
+ # @!method must_have_title
126
+ # See {Capybara::Node::DocumentMatchers#has_title?}
127
+
128
+ ##
129
+ # Expectation that page title does not match
130
+ #
131
+ # @!method wont_have_title
132
+ # See {Capybara::Node::DocumentMatchers#has_no_title?}
128
133
 
129
134
  ##
130
135
  # Expectation that there is select
131
136
  #
132
137
  # @!method must_have_select
133
- # see {Capybara::Node::Matchers#has_select?}
138
+ # See {Capybara::Node::Matchers#has_select?}
134
139
 
135
140
  ##
136
141
  # Expectation that there is no select
137
142
  #
138
143
  # @!method wont_have_select
139
- # see {Capybara::Node::Matchers#has_no_select?}
144
+ # See {Capybara::Node::Matchers#has_no_select?}
140
145
 
141
146
  ##
142
- # Expectation that there is table
147
+ # Expectation that there is a selector
143
148
  #
144
- # @!method must_have_table
145
- # see {Capybara::Node::Matchers#has_table?}
149
+ # @!method must_have_selector
150
+ # See {Capybara::Node::Matchers#has_selector?}
146
151
 
147
152
  ##
148
- # Expectation that there is no table
153
+ # Expectation that there is no selector
149
154
  #
150
- # @!method wont_have_table
151
- # see {Capybara::Node::Matchers#has_no_table?}
155
+ # @!method wont_have_selector
156
+ # See {Capybara::Node::Matchers#has_no_selector?}
152
157
 
153
158
  ##
154
- # Expectation that page title does match
159
+ # Expectation that all of the provided selectors are present
155
160
  #
156
- # @!method must_have_title
157
- # see {Capybara::Node::DocumentMatchers#assert_title}
161
+ # @!method must_have_all_of_selectors
162
+ # See {Capybara::Node::Matchers#assert_all_of_selectors}
158
163
 
159
164
  ##
160
- # Expectation that page title does not match
165
+ # Expectation that none of the provided selectors are present
161
166
  #
162
- # @!method wont_have_title
163
- # see {Capybara::Node::DocumentMatchers#assert_no_title}
167
+ # @!method must_have_none_of_selectors
168
+ # See {Capybara::Node::Matchers#assert_none_of_selectors}
164
169
 
165
170
  ##
166
- # Expectation that current path matches
171
+ # Expectation that any of the provided selectors are present
167
172
  #
168
- # @!method must_have_current_path
169
- # see {Capybara::SessionMatchers#assert_current_path}
173
+ # @!method must_have_any_of_selectors
174
+ # See {Capybara::Node::Matchers#assert_any_of_selectors}
170
175
 
171
176
  ##
172
- # Expectation that current page does not match
177
+ # Expectation that there is a sibling
173
178
  #
174
- # @!method wont_have_current_path
175
- # see {Capybara::SessionMatchers#assert_no_current_path}
179
+ # @!method must_have_sibling
180
+ # See {Capybara::Node::Matchers#has_sibling?}
176
181
 
177
182
  ##
178
183
  # Expectation that element has style
179
184
  #
180
185
  # @!method must_match_style
181
- # see {Capybara::Node::Matchers#assert_matches_style}
186
+ # See {Capybara::Node::Matchers#matches_style?}
182
187
 
183
188
  ##
184
- # Expectation that there is an ancestor
189
+ # Expectation that there is table
185
190
  #
186
- # @!method must_have_ancestor
187
- # see Capybara::Node::Matchers#has_ancestor?
191
+ # @!method must_have_table
192
+ # See {Capybara::Node::Matchers#has_table?}
188
193
 
189
194
  ##
190
- # Expectation that there is a sibling
195
+ # Expectation that there is no table
191
196
  #
192
- # @!method must_have_sibling
193
- # see Capybara::Node::Matchers#has_sibling?
197
+ # @!method wont_have_table
198
+ # See {Capybara::Node::Matchers#has_no_table?}
199
+
200
+ ##
201
+ # Expectation that there is xpath
202
+ #
203
+ # @!method must_have_xpath
204
+ # See {Capybara::Node::Matchers#has_xpath?}
205
+
206
+ ##
207
+ # Expectation that there is no xpath
208
+ #
209
+ # @!method wont_have_xpath
210
+ # See {Capybara::Node::Matchers#has_no_xpath?}
211
+
212
+ # This currently doesn't work for Ruby 2.8 due to Minitest not forwarding keyword args separately
213
+ # %w[text content title current_path].each do |assertion|
214
+ # infect_an_assertion "assert_#{assertion}", "must_have_#{assertion}", :reverse
215
+ # infect_an_assertion "refute_#{assertion}", "wont_have_#{assertion}", :reverse
216
+ # end
217
+
218
+ # rubocop:disable Style/MultilineBlockChain
219
+ (%w[text content title current_path
220
+ selector xpath css link button field select table checked_field unchecked_field
221
+ ancestor sibling].flat_map do |assertion|
222
+ [%W[assert_#{assertion} must_have_#{assertion}],
223
+ %W[refute_#{assertion} wont_have_#{assertion}]]
224
+ end + [%w[assert_all_of_selectors must_have_all_of_selectors],
225
+ %w[assert_none_of_selectors must_have_none_of_selectors],
226
+ %w[assert_any_of_selectors must_have_any_of_selectors],
227
+ %w[assert_matches_style must_match_style]] +
228
+ %w[selector xpath css].flat_map do |assertion|
229
+ [%W[assert_matches_#{assertion} must_match_#{assertion}],
230
+ %W[refute_matches_#{assertion} wont_match_#{assertion}]]
231
+ end).each do |(meth, new_name)|
232
+ class_eval <<-ASSERTION, __FILE__, __LINE__ + 1
233
+ def #{new_name} *args, **kw_args, &block
234
+ ::Minitest::Expectation.new(self, ::Minitest::Spec.current).#{new_name}(*args, **kw_args, &block)
235
+ end
236
+ ASSERTION
237
+
238
+ ::Minitest::Expectation.class_eval <<-ASSERTION, __FILE__, __LINE__ + 1
239
+ def #{new_name} *args, **kw_args, &block
240
+ raise "Calling ##{new_name} outside of test." unless ctx
241
+ ctx.#{meth}(target, *args, **kw_args, &block)
242
+ end
243
+ ASSERTION
244
+ end
245
+ # rubocop:enable Style/MultilineBlockChain
246
+
247
+ ##
248
+ # @deprecated
249
+ def must_have_style(...)
250
+ warn 'must_have_style is deprecated, please use must_match_style'
251
+ must_match_style(...)
252
+ end
194
253
  end
195
254
  end
196
255
  end