capybara 3.29.0 → 3.31.0
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.
- checksums.yaml +4 -4
- data/History.md +40 -1
- data/README.md +1 -1
- data/lib/capybara/config.rb +7 -3
- data/lib/capybara/dsl.rb +10 -2
- data/lib/capybara/helpers.rb +3 -1
- data/lib/capybara/minitest.rb +18 -4
- data/lib/capybara/node/actions.rb +23 -19
- data/lib/capybara/node/document.rb +2 -2
- data/lib/capybara/node/document_matchers.rb +3 -3
- data/lib/capybara/node/element.rb +21 -16
- data/lib/capybara/node/finders.rb +17 -11
- data/lib/capybara/node/matchers.rb +60 -45
- data/lib/capybara/node/simple.rb +4 -2
- data/lib/capybara/queries/ancestor_query.rb +1 -1
- data/lib/capybara/queries/base_query.rb +2 -1
- data/lib/capybara/queries/selector_query.rb +17 -4
- data/lib/capybara/queries/sibling_query.rb +1 -1
- data/lib/capybara/rack_test/browser.rb +4 -1
- data/lib/capybara/rack_test/driver.rb +1 -1
- data/lib/capybara/rack_test/form.rb +1 -1
- data/lib/capybara/rack_test/node.rb +34 -9
- data/lib/capybara/result.rb +24 -4
- data/lib/capybara/rspec/matchers.rb +27 -27
- data/lib/capybara/rspec/matchers/base.rb +12 -6
- data/lib/capybara/rspec/matchers/count_sugar.rb +2 -1
- data/lib/capybara/rspec/matchers/have_ancestor.rb +4 -3
- data/lib/capybara/rspec/matchers/have_current_path.rb +2 -2
- data/lib/capybara/rspec/matchers/have_selector.rb +15 -7
- data/lib/capybara/rspec/matchers/have_sibling.rb +3 -3
- data/lib/capybara/rspec/matchers/have_text.rb +2 -2
- data/lib/capybara/rspec/matchers/have_title.rb +2 -2
- data/lib/capybara/rspec/matchers/match_selector.rb +3 -3
- data/lib/capybara/rspec/matchers/match_style.rb +2 -2
- data/lib/capybara/rspec/matchers/spatial_sugar.rb +2 -1
- data/lib/capybara/selector.rb +24 -16
- data/lib/capybara/selector/css.rb +1 -1
- data/lib/capybara/selector/definition.rb +2 -2
- data/lib/capybara/selector/definition/button.rb +7 -2
- data/lib/capybara/selector/definition/checkbox.rb +2 -2
- data/lib/capybara/selector/definition/css.rb +3 -1
- data/lib/capybara/selector/definition/datalist_input.rb +1 -1
- data/lib/capybara/selector/definition/datalist_option.rb +1 -1
- data/lib/capybara/selector/definition/element.rb +1 -1
- data/lib/capybara/selector/definition/field.rb +1 -1
- data/lib/capybara/selector/definition/file_field.rb +1 -1
- data/lib/capybara/selector/definition/fillable_field.rb +1 -1
- data/lib/capybara/selector/definition/label.rb +4 -2
- data/lib/capybara/selector/definition/radio_button.rb +2 -2
- data/lib/capybara/selector/definition/select.rb +32 -13
- data/lib/capybara/selector/definition/table.rb +5 -2
- data/lib/capybara/selector/filter_set.rb +11 -9
- data/lib/capybara/selector/filters/base.rb +6 -1
- data/lib/capybara/selector/filters/locator_filter.rb +1 -1
- data/lib/capybara/selector/selector.rb +4 -2
- data/lib/capybara/selenium/driver.rb +19 -11
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +1 -1
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +2 -2
- data/lib/capybara/selenium/extensions/html5_drag.rb +30 -13
- data/lib/capybara/selenium/node.rb +29 -10
- data/lib/capybara/selenium/nodes/chrome_node.rb +11 -5
- data/lib/capybara/selenium/nodes/edge_node.rb +4 -2
- data/lib/capybara/selenium/nodes/firefox_node.rb +2 -2
- data/lib/capybara/server.rb +15 -3
- data/lib/capybara/server/checker.rb +1 -1
- data/lib/capybara/server/middleware.rb +20 -10
- data/lib/capybara/session.rb +40 -23
- data/lib/capybara/session/config.rb +6 -2
- data/lib/capybara/session/matchers.rb +6 -6
- data/lib/capybara/spec/public/test.js +51 -6
- data/lib/capybara/spec/session/all_spec.rb +60 -5
- data/lib/capybara/spec/session/ancestor_spec.rb +5 -0
- data/lib/capybara/spec/session/assert_text_spec.rb +9 -5
- data/lib/capybara/spec/session/click_button_spec.rb +5 -0
- data/lib/capybara/spec/session/fill_in_spec.rb +20 -0
- data/lib/capybara/spec/session/find_spec.rb +20 -0
- data/lib/capybara/spec/session/has_css_spec.rb +3 -3
- data/lib/capybara/spec/session/has_select_spec.rb +28 -0
- data/lib/capybara/spec/session/has_table_spec.rb +51 -5
- data/lib/capybara/spec/session/has_text_spec.rb +35 -0
- data/lib/capybara/spec/session/node_spec.rb +106 -2
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +2 -2
- data/lib/capybara/spec/session/save_screenshot_spec.rb +4 -4
- data/lib/capybara/spec/session/selectors_spec.rb +15 -2
- data/lib/capybara/spec/views/form.erb +11 -1
- data/lib/capybara/version.rb +1 -1
- data/spec/dsl_spec.rb +2 -2
- data/spec/minitest_spec_spec.rb +46 -46
- data/spec/rack_test_spec.rb +0 -1
- data/spec/regexp_dissassembler_spec.rb +45 -37
- data/spec/result_spec.rb +7 -3
- data/spec/rspec/features_spec.rb +1 -0
- data/spec/rspec/shared_spec_matchers.rb +3 -3
- data/spec/rspec_spec.rb +4 -4
- data/spec/selenium_spec_chrome.rb +5 -4
- data/spec/selenium_spec_firefox.rb +7 -2
- data/spec/server_spec.rb +42 -0
- data/spec/session_spec.rb +1 -1
- data/spec/shared_selenium_node.rb +3 -3
- data/spec/shared_selenium_session.rb +8 -7
- metadata +3 -3
@@ -49,7 +49,7 @@ module Capybara
|
|
49
49
|
#
|
50
50
|
def find(*args, **options, &optional_filter_block)
|
51
51
|
options[:session_options] = session_options
|
52
|
-
synced_resolve Capybara::Queries::SelectorQuery.new(*args, options, &optional_filter_block)
|
52
|
+
synced_resolve Capybara::Queries::SelectorQuery.new(*args, **options, &optional_filter_block)
|
53
53
|
end
|
54
54
|
|
55
55
|
##
|
@@ -72,7 +72,7 @@ module Capybara
|
|
72
72
|
#
|
73
73
|
def ancestor(*args, **options, &optional_filter_block)
|
74
74
|
options[:session_options] = session_options
|
75
|
-
synced_resolve Capybara::Queries::AncestorQuery.new(*args, options, &optional_filter_block)
|
75
|
+
synced_resolve Capybara::Queries::AncestorQuery.new(*args, **options, &optional_filter_block)
|
76
76
|
end
|
77
77
|
|
78
78
|
##
|
@@ -95,7 +95,7 @@ module Capybara
|
|
95
95
|
#
|
96
96
|
def sibling(*args, **options, &optional_filter_block)
|
97
97
|
options[:session_options] = session_options
|
98
|
-
synced_resolve Capybara::Queries::SiblingQuery.new(*args, options, &optional_filter_block)
|
98
|
+
synced_resolve Capybara::Queries::SiblingQuery.new(*args, **options, &optional_filter_block)
|
99
99
|
end
|
100
100
|
|
101
101
|
##
|
@@ -125,7 +125,7 @@ module Capybara
|
|
125
125
|
# @return [Capybara::Node::Element] The found element
|
126
126
|
#
|
127
127
|
def find_field(locator = nil, **options, &optional_filter_block)
|
128
|
-
find(:field, locator, options, &optional_filter_block)
|
128
|
+
find(:field, locator, **options, &optional_filter_block)
|
129
129
|
end
|
130
130
|
|
131
131
|
##
|
@@ -145,7 +145,7 @@ module Capybara
|
|
145
145
|
# @return [Capybara::Node::Element] The found element
|
146
146
|
#
|
147
147
|
def find_link(locator = nil, **options, &optional_filter_block)
|
148
|
-
find(:link, locator, options, &optional_filter_block)
|
148
|
+
find(:link, locator, **options, &optional_filter_block)
|
149
149
|
end
|
150
150
|
|
151
151
|
##
|
@@ -172,7 +172,7 @@ module Capybara
|
|
172
172
|
# @return [Capybara::Node::Element] The found element
|
173
173
|
#
|
174
174
|
def find_button(locator = nil, **options, &optional_filter_block)
|
175
|
-
find(:button, locator, options, &optional_filter_block)
|
175
|
+
find(:button, locator, **options, &optional_filter_block)
|
176
176
|
end
|
177
177
|
|
178
178
|
##
|
@@ -186,7 +186,7 @@ module Capybara
|
|
186
186
|
# @return [Capybara::Node::Element] The found element
|
187
187
|
#
|
188
188
|
def find_by_id(id, **options, &optional_filter_block)
|
189
|
-
find(:id, id, options, &optional_filter_block)
|
189
|
+
find(:id, id, **options, &optional_filter_block)
|
190
190
|
end
|
191
191
|
|
192
192
|
##
|
@@ -235,21 +235,25 @@ module Capybara
|
|
235
235
|
# @option options [Integer] maximum Maximum number of matches that are expected to be found
|
236
236
|
# @option options [Integer] minimum Minimum number of matches that are expected to be found
|
237
237
|
# @option options [Range] between Number of matches found must be within the given range
|
238
|
+
# @option options [Boolean] allow_reload Beta feature - May be removed in any version.
|
239
|
+
# When `true` allows elements to be reloaded if they become stale. This is an advanced behavior and should only be used
|
240
|
+
# if you fully understand the potential ramifications. The results can be confusing on dynamic pages. Defaults to `false`
|
238
241
|
# @overload all([kind = Capybara.default_selector], locator = nil, **options)
|
239
242
|
# @overload all([kind = Capybara.default_selector], locator = nil, **options, &filter_block)
|
240
243
|
# @yieldparam element [Capybara::Node::Element] The element being considered for inclusion in the results
|
241
244
|
# @yieldreturn [Boolean] Should the element be considered in the results?
|
242
245
|
# @return [Capybara::Result] A collection of found elements
|
243
246
|
# @raise [Capybara::ExpectationNotMet] The number of elements found doesn't match the specified conditions
|
244
|
-
def all(*args, **options, &optional_filter_block)
|
247
|
+
def all(*args, allow_reload: false, **options, &optional_filter_block)
|
245
248
|
minimum_specified = options_include_minimum?(options)
|
246
249
|
options = { minimum: 1 }.merge(options) unless minimum_specified
|
247
250
|
options[:session_options] = session_options
|
248
|
-
query = Capybara::Queries::SelectorQuery.new(*args, options, &optional_filter_block)
|
251
|
+
query = Capybara::Queries::SelectorQuery.new(*args, **options, &optional_filter_block)
|
249
252
|
result = nil
|
250
253
|
begin
|
251
254
|
synchronize(query.wait) do
|
252
255
|
result = query.resolve_for(self)
|
256
|
+
result.allow_reload! if allow_reload
|
253
257
|
raise Capybara::ExpectationNotMet, result.failure_message unless result.matches_count?
|
254
258
|
|
255
259
|
result
|
@@ -278,7 +282,7 @@ module Capybara
|
|
278
282
|
#
|
279
283
|
def first(*args, **options, &optional_filter_block)
|
280
284
|
options = { minimum: 1 }.merge(options) unless options_include_minimum?(options)
|
281
|
-
all(*args, options, &optional_filter_block).first
|
285
|
+
all(*args, **options, &optional_filter_block).first
|
282
286
|
end
|
283
287
|
|
284
288
|
private
|
@@ -292,7 +296,9 @@ module Capybara
|
|
292
296
|
result = query.resolve_for(self)
|
293
297
|
end
|
294
298
|
|
295
|
-
|
299
|
+
if ambiguous?(query, result)
|
300
|
+
raise Capybara::Ambiguous, "Ambiguous match, found #{result.size} elements matching #{query.applied_description}"
|
301
|
+
end
|
296
302
|
raise Capybara::ElementNotFound, "Unable to find #{query.applied_description}" if result.empty?
|
297
303
|
|
298
304
|
result.first
|
@@ -61,7 +61,7 @@ module Capybara
|
|
61
61
|
# @return [Boolean] If the styles match
|
62
62
|
#
|
63
63
|
def matches_style?(styles, **options)
|
64
|
-
make_predicate(options) { assert_matches_style(styles, options) }
|
64
|
+
make_predicate(options) { assert_matches_style(styles, **options) }
|
65
65
|
end
|
66
66
|
|
67
67
|
##
|
@@ -107,7 +107,9 @@ module Capybara
|
|
107
107
|
#
|
108
108
|
def assert_selector(*args, &optional_filter_block)
|
109
109
|
_verify_selector_result(args, optional_filter_block) do |result, query|
|
110
|
-
|
110
|
+
unless result.matches_count? && (result.any? || query.expects_none?)
|
111
|
+
raise Capybara::ExpectationNotMet, result.failure_message
|
112
|
+
end
|
111
113
|
end
|
112
114
|
end
|
113
115
|
|
@@ -121,8 +123,8 @@ module Capybara
|
|
121
123
|
# @raise [Capybara::ExpectationNotMet] If the element doesn't have the specified styles
|
122
124
|
#
|
123
125
|
def assert_matches_style(styles, **options)
|
124
|
-
query_args = _set_query_session_options(styles, options)
|
125
|
-
query = Capybara::Queries::StyleQuery.new(*query_args)
|
126
|
+
query_args, query_opts = _set_query_session_options(styles, options)
|
127
|
+
query = Capybara::Queries::StyleQuery.new(*query_args, **query_opts)
|
126
128
|
synchronize(query.wait) do
|
127
129
|
raise Capybara::ExpectationNotMet, query.failure_message unless query.resolves_for?(self)
|
128
130
|
end
|
@@ -153,7 +155,7 @@ module Capybara
|
|
153
155
|
# @overload assert_all_of_selectors([kind = Capybara.default_selector], *locators, **options)
|
154
156
|
#
|
155
157
|
def assert_all_of_selectors(*args, **options, &optional_filter_block)
|
156
|
-
_verify_multiple(*args, options) do |selector, locator, opts|
|
158
|
+
_verify_multiple(*args, **options) do |selector, locator, opts|
|
157
159
|
assert_selector(selector, locator, opts, &optional_filter_block)
|
158
160
|
end
|
159
161
|
end
|
@@ -174,7 +176,7 @@ module Capybara
|
|
174
176
|
# @overload assert_none_of_selectors([kind = Capybara.default_selector], *locators, **options)
|
175
177
|
#
|
176
178
|
def assert_none_of_selectors(*args, **options, &optional_filter_block)
|
177
|
-
_verify_multiple(*args, options) do |selector, locator, opts|
|
179
|
+
_verify_multiple(*args, **options) do |selector, locator, opts|
|
178
180
|
assert_no_selector(selector, locator, opts, &optional_filter_block)
|
179
181
|
end
|
180
182
|
end
|
@@ -266,7 +268,7 @@ module Capybara
|
|
266
268
|
# @return [Boolean] If the expression exists
|
267
269
|
#
|
268
270
|
def has_xpath?(path, **options, &optional_filter_block)
|
269
|
-
has_selector?(:xpath, path, options, &optional_filter_block)
|
271
|
+
has_selector?(:xpath, path, **options, &optional_filter_block)
|
270
272
|
end
|
271
273
|
|
272
274
|
##
|
@@ -278,7 +280,7 @@ module Capybara
|
|
278
280
|
# @return [Boolean]
|
279
281
|
#
|
280
282
|
def has_no_xpath?(path, **options, &optional_filter_block)
|
281
|
-
has_no_selector?(:xpath, path, options, &optional_filter_block)
|
283
|
+
has_no_selector?(:xpath, path, **options, &optional_filter_block)
|
282
284
|
end
|
283
285
|
|
284
286
|
##
|
@@ -305,7 +307,7 @@ module Capybara
|
|
305
307
|
# @return [Boolean] If the selector exists
|
306
308
|
#
|
307
309
|
def has_css?(path, **options, &optional_filter_block)
|
308
|
-
has_selector?(:css, path, options, &optional_filter_block)
|
310
|
+
has_selector?(:css, path, **options, &optional_filter_block)
|
309
311
|
end
|
310
312
|
|
311
313
|
##
|
@@ -317,7 +319,7 @@ module Capybara
|
|
317
319
|
# @return [Boolean]
|
318
320
|
#
|
319
321
|
def has_no_css?(path, **options, &optional_filter_block)
|
320
|
-
has_no_selector?(:css, path, options, &optional_filter_block)
|
322
|
+
has_no_selector?(:css, path, **options, &optional_filter_block)
|
321
323
|
end
|
322
324
|
|
323
325
|
##
|
@@ -330,7 +332,7 @@ module Capybara
|
|
330
332
|
# @return [Boolean] Whether it exists
|
331
333
|
#
|
332
334
|
def has_link?(locator = nil, **options, &optional_filter_block)
|
333
|
-
has_selector?(:link, locator, options, &optional_filter_block)
|
335
|
+
has_selector?(:link, locator, **options, &optional_filter_block)
|
334
336
|
end
|
335
337
|
|
336
338
|
##
|
@@ -342,7 +344,7 @@ module Capybara
|
|
342
344
|
# @return [Boolean] Whether it doesn't exist
|
343
345
|
#
|
344
346
|
def has_no_link?(locator = nil, **options, &optional_filter_block)
|
345
|
-
has_no_selector?(:link, locator, options, &optional_filter_block)
|
347
|
+
has_no_selector?(:link, locator, **options, &optional_filter_block)
|
346
348
|
end
|
347
349
|
|
348
350
|
##
|
@@ -354,7 +356,7 @@ module Capybara
|
|
354
356
|
# @return [Boolean] Whether it exists
|
355
357
|
#
|
356
358
|
def has_button?(locator = nil, **options, &optional_filter_block)
|
357
|
-
has_selector?(:button, locator, options, &optional_filter_block)
|
359
|
+
has_selector?(:button, locator, **options, &optional_filter_block)
|
358
360
|
end
|
359
361
|
|
360
362
|
##
|
@@ -366,7 +368,7 @@ module Capybara
|
|
366
368
|
# @return [Boolean] Whether it doesn't exist
|
367
369
|
#
|
368
370
|
def has_no_button?(locator = nil, **options, &optional_filter_block)
|
369
|
-
has_no_selector?(:button, locator, options, &optional_filter_block)
|
371
|
+
has_no_selector?(:button, locator, **options, &optional_filter_block)
|
370
372
|
end
|
371
373
|
|
372
374
|
##
|
@@ -392,7 +394,7 @@ module Capybara
|
|
392
394
|
# @return [Boolean] Whether it exists
|
393
395
|
#
|
394
396
|
def has_field?(locator = nil, **options, &optional_filter_block)
|
395
|
-
has_selector?(:field, locator, options, &optional_filter_block)
|
397
|
+
has_selector?(:field, locator, **options, &optional_filter_block)
|
396
398
|
end
|
397
399
|
|
398
400
|
##
|
@@ -406,7 +408,7 @@ module Capybara
|
|
406
408
|
# @return [Boolean] Whether it doesn't exist
|
407
409
|
#
|
408
410
|
def has_no_field?(locator = nil, **options, &optional_filter_block)
|
409
|
-
has_no_selector?(:field, locator, options, &optional_filter_block)
|
411
|
+
has_no_selector?(:field, locator, **options, &optional_filter_block)
|
410
412
|
end
|
411
413
|
|
412
414
|
##
|
@@ -419,7 +421,7 @@ module Capybara
|
|
419
421
|
# @return [Boolean] Whether it exists
|
420
422
|
#
|
421
423
|
def has_checked_field?(locator = nil, **options, &optional_filter_block)
|
422
|
-
has_selector?(:field, locator, options.merge(checked: true), &optional_filter_block)
|
424
|
+
has_selector?(:field, locator, **options.merge(checked: true), &optional_filter_block)
|
423
425
|
end
|
424
426
|
|
425
427
|
##
|
@@ -432,7 +434,7 @@ module Capybara
|
|
432
434
|
# @return [Boolean] Whether it doesn't exist
|
433
435
|
#
|
434
436
|
def has_no_checked_field?(locator = nil, **options, &optional_filter_block)
|
435
|
-
has_no_selector?(:field, locator, options.merge(checked: true), &optional_filter_block)
|
437
|
+
has_no_selector?(:field, locator, **options.merge(checked: true), &optional_filter_block)
|
436
438
|
end
|
437
439
|
|
438
440
|
##
|
@@ -445,7 +447,7 @@ module Capybara
|
|
445
447
|
# @return [Boolean] Whether it exists
|
446
448
|
#
|
447
449
|
def has_unchecked_field?(locator = nil, **options, &optional_filter_block)
|
448
|
-
has_selector?(:field, locator, options.merge(unchecked: true), &optional_filter_block)
|
450
|
+
has_selector?(:field, locator, **options.merge(unchecked: true), &optional_filter_block)
|
449
451
|
end
|
450
452
|
|
451
453
|
##
|
@@ -458,7 +460,7 @@ module Capybara
|
|
458
460
|
# @return [Boolean] Whether it doesn't exist
|
459
461
|
#
|
460
462
|
def has_no_unchecked_field?(locator = nil, **options, &optional_filter_block)
|
461
|
-
has_no_selector?(:field, locator, options.merge(unchecked: true), &optional_filter_block)
|
463
|
+
has_no_selector?(:field, locator, **options.merge(unchecked: true), &optional_filter_block)
|
462
464
|
end
|
463
465
|
|
464
466
|
##
|
@@ -491,7 +493,7 @@ module Capybara
|
|
491
493
|
# @return [Boolean] Whether it exists
|
492
494
|
#
|
493
495
|
def has_select?(locator = nil, **options, &optional_filter_block)
|
494
|
-
has_selector?(:select, locator, options, &optional_filter_block)
|
496
|
+
has_selector?(:select, locator, **options, &optional_filter_block)
|
495
497
|
end
|
496
498
|
|
497
499
|
##
|
@@ -503,7 +505,7 @@ module Capybara
|
|
503
505
|
# @return [Boolean] Whether it doesn't exist
|
504
506
|
#
|
505
507
|
def has_no_select?(locator = nil, **options, &optional_filter_block)
|
506
|
-
has_no_selector?(:select, locator, options, &optional_filter_block)
|
508
|
+
has_no_selector?(:select, locator, **options, &optional_filter_block)
|
507
509
|
end
|
508
510
|
|
509
511
|
##
|
@@ -525,7 +527,7 @@ module Capybara
|
|
525
527
|
# @return [Boolean] Whether it exists
|
526
528
|
#
|
527
529
|
def has_table?(locator = nil, **options, &optional_filter_block)
|
528
|
-
has_selector?(:table, locator, options, &optional_filter_block)
|
530
|
+
has_selector?(:table, locator, **options, &optional_filter_block)
|
529
531
|
end
|
530
532
|
|
531
533
|
##
|
@@ -537,7 +539,7 @@ module Capybara
|
|
537
539
|
# @return [Boolean] Whether it doesn't exist
|
538
540
|
#
|
539
541
|
def has_no_table?(locator = nil, **options, &optional_filter_block)
|
540
|
-
has_no_selector?(:table, locator, options, &optional_filter_block)
|
542
|
+
has_no_selector?(:table, locator, **options, &optional_filter_block)
|
541
543
|
end
|
542
544
|
|
543
545
|
##
|
@@ -595,7 +597,7 @@ module Capybara
|
|
595
597
|
# @return [Boolean]
|
596
598
|
#
|
597
599
|
def matches_xpath?(xpath, **options, &optional_filter_block)
|
598
|
-
matches_selector?(:xpath, xpath, options, &optional_filter_block)
|
600
|
+
matches_selector?(:xpath, xpath, **options, &optional_filter_block)
|
599
601
|
end
|
600
602
|
|
601
603
|
##
|
@@ -606,7 +608,7 @@ module Capybara
|
|
606
608
|
# @return [Boolean]
|
607
609
|
#
|
608
610
|
def matches_css?(css, **options, &optional_filter_block)
|
609
|
-
matches_selector?(:css, css, options, &optional_filter_block)
|
611
|
+
matches_selector?(:css, css, **options, &optional_filter_block)
|
610
612
|
end
|
611
613
|
|
612
614
|
##
|
@@ -629,7 +631,7 @@ module Capybara
|
|
629
631
|
# @return [Boolean]
|
630
632
|
#
|
631
633
|
def not_matches_xpath?(xpath, **options, &optional_filter_block)
|
632
|
-
not_matches_selector?(:xpath, xpath, options, &optional_filter_block)
|
634
|
+
not_matches_selector?(:xpath, xpath, **options, &optional_filter_block)
|
633
635
|
end
|
634
636
|
|
635
637
|
##
|
@@ -640,7 +642,7 @@ module Capybara
|
|
640
642
|
# @return [Boolean]
|
641
643
|
#
|
642
644
|
def not_matches_css?(css, **options, &optional_filter_block)
|
643
|
-
not_matches_selector?(:css, css, options, &optional_filter_block)
|
645
|
+
not_matches_selector?(:css, css, **options, &optional_filter_block)
|
644
646
|
end
|
645
647
|
|
646
648
|
##
|
@@ -670,8 +672,8 @@ module Capybara
|
|
670
672
|
# @raise [Capybara::ExpectationNotMet] if the assertion hasn't succeeded during wait time
|
671
673
|
# @return [true]
|
672
674
|
#
|
673
|
-
def assert_text(*args)
|
674
|
-
_verify_text(args) do |count, query|
|
675
|
+
def assert_text(type_or_text, *args, **opts)
|
676
|
+
_verify_text(type_or_text, *args, **opts) do |count, query|
|
675
677
|
unless query.matches_count?(count) && (count.positive? || query.expects_none?)
|
676
678
|
raise Capybara::ExpectationNotMet, query.failure_message
|
677
679
|
end
|
@@ -686,8 +688,8 @@ module Capybara
|
|
686
688
|
# @raise [Capybara::ExpectationNotMet] if the assertion hasn't succeeded during wait time
|
687
689
|
# @return [true]
|
688
690
|
#
|
689
|
-
def assert_no_text(*args)
|
690
|
-
_verify_text(args) do |count, query|
|
691
|
+
def assert_no_text(type_or_text, *args, **opts)
|
692
|
+
_verify_text(type_or_text, *args, **opts) do |count, query|
|
691
693
|
if query.matches_count?(count) && (count.positive? || query.expects_none?)
|
692
694
|
raise Capybara::ExpectationNotMet, query.negative_failure_message
|
693
695
|
end
|
@@ -709,7 +711,7 @@ module Capybara
|
|
709
711
|
# @return [Boolean] Whether it exists
|
710
712
|
#
|
711
713
|
def has_text?(*args, **options)
|
712
|
-
make_predicate(options) { assert_text(*args, options) }
|
714
|
+
make_predicate(options) { assert_text(*args, **options) }
|
713
715
|
end
|
714
716
|
alias_method :has_content?, :has_text?
|
715
717
|
|
@@ -721,7 +723,7 @@ module Capybara
|
|
721
723
|
# @return [Boolean] Whether it doesn't exist
|
722
724
|
#
|
723
725
|
def has_no_text?(*args, **options)
|
724
|
-
make_predicate(options) { assert_no_text(*args, options) }
|
726
|
+
make_predicate(options) { assert_no_text(*args, **options) }
|
725
727
|
end
|
726
728
|
alias_method :has_no_content?, :has_no_text?
|
727
729
|
|
@@ -738,7 +740,9 @@ module Capybara
|
|
738
740
|
#
|
739
741
|
def assert_ancestor(*args, &optional_filter_block)
|
740
742
|
_verify_selector_result(args, optional_filter_block, Capybara::Queries::AncestorQuery) do |result, query|
|
741
|
-
|
743
|
+
unless result.matches_count? && (result.any? || query.expects_none?)
|
744
|
+
raise Capybara::ExpectationNotMet, result.failure_message
|
745
|
+
end
|
742
746
|
end
|
743
747
|
end
|
744
748
|
|
@@ -779,7 +783,9 @@ module Capybara
|
|
779
783
|
#
|
780
784
|
def assert_sibling(*args, &optional_filter_block)
|
781
785
|
_verify_selector_result(args, optional_filter_block, Capybara::Queries::SiblingQuery) do |result, query|
|
782
|
-
|
786
|
+
unless result.matches_count? && (result.any? || query.expects_none?)
|
787
|
+
raise Capybara::ExpectationNotMet, result.failure_message
|
788
|
+
end
|
783
789
|
end
|
784
790
|
end
|
785
791
|
|
@@ -826,8 +832,14 @@ module Capybara
|
|
826
832
|
end
|
827
833
|
|
828
834
|
def _verify_selector_result(query_args, optional_filter_block, query_type = Capybara::Queries::SelectorQuery)
|
829
|
-
query_args =
|
830
|
-
|
835
|
+
# query_args, query_opts = if query_args[0].is_a? Symbol
|
836
|
+
# a,o = _set_query_session_options(*query_args.slice(2..))
|
837
|
+
# [query_args.slice(0..1).concat(a), o]
|
838
|
+
# else
|
839
|
+
# _set_query_session_options(*query_args)
|
840
|
+
# end
|
841
|
+
query_args, query_opts = _set_query_session_options(*query_args)
|
842
|
+
query = query_type.new(*query_args, **query_opts, &optional_filter_block)
|
831
843
|
synchronize(query.wait) do
|
832
844
|
yield query.resolve_for(self), query
|
833
845
|
end
|
@@ -835,26 +847,29 @@ module Capybara
|
|
835
847
|
end
|
836
848
|
|
837
849
|
def _verify_match_result(query_args, optional_filter_block)
|
838
|
-
query_args = _set_query_session_options(*query_args)
|
839
|
-
query = Capybara::Queries::MatchQuery.new(*query_args, &optional_filter_block)
|
850
|
+
query_args, query_opts = _set_query_session_options(*query_args)
|
851
|
+
query = Capybara::Queries::MatchQuery.new(*query_args, **query_opts, &optional_filter_block)
|
840
852
|
synchronize(query.wait) do
|
841
853
|
yield query.resolve_for(parent || session&.document || query_scope)
|
842
854
|
end
|
843
855
|
true
|
844
856
|
end
|
845
857
|
|
846
|
-
def _verify_text(
|
847
|
-
|
848
|
-
query = Capybara::Queries::TextQuery.new(
|
858
|
+
def _verify_text(type = nil, expected_text, **query_options) # rubocop:disable Style/OptionalArguments
|
859
|
+
query_options[:session_options] = session_options
|
860
|
+
query = Capybara::Queries::TextQuery.new(type, expected_text, **query_options)
|
849
861
|
synchronize(query.wait) do
|
850
862
|
yield query.resolve_for(self), query
|
851
863
|
end
|
852
864
|
true
|
853
865
|
end
|
854
866
|
|
855
|
-
def _set_query_session_options(*query_args
|
867
|
+
def _set_query_session_options(*query_args)
|
868
|
+
query_args, query_options = query_args.dup, {}
|
869
|
+
# query_options = query_args.pop if query_options.empty? && query_args.last.is_a?(Hash)
|
870
|
+
query_options = query_args.pop if query_args.last.is_a?(Hash)
|
856
871
|
query_options[:session_options] = session_options
|
857
|
-
query_args
|
872
|
+
[query_args, query_options]
|
858
873
|
end
|
859
874
|
|
860
875
|
def make_predicate(options)
|