Prevent race conditions when checking negative assertions, closes #843
This commit is contained in:
parent
45e00f60e1
commit
792781f00b
|
@ -76,6 +76,7 @@ module Capybara
|
|||
begin
|
||||
yield
|
||||
rescue => e
|
||||
raise e if @unsynchronized
|
||||
raise e unless driver.wait?
|
||||
raise e unless driver.invalid_element_errors.include?(e.class) || e.is_a?(Capybara::ElementNotFound)
|
||||
raise e if (Time.now - start_time) >= seconds
|
||||
|
@ -86,6 +87,24 @@ module Capybara
|
|||
end
|
||||
end
|
||||
|
||||
##
|
||||
#
|
||||
# Within the given block, prevent synchronize from having any effect.
|
||||
#
|
||||
# This is an internal method which should not be called unless you are
|
||||
# absolutely sure of what you're doing.
|
||||
#
|
||||
# @api private
|
||||
# @return [Object] The result of the given block
|
||||
#
|
||||
def unsynchronized
|
||||
orig = @unsynchronized
|
||||
@unsynchronized = true
|
||||
yield
|
||||
ensure
|
||||
@unsynchronized = orig
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def driver
|
||||
|
|
|
@ -35,15 +35,17 @@ module Capybara
|
|||
end
|
||||
|
||||
def matches_filters?(node)
|
||||
if options[:text]
|
||||
regexp = options[:text].is_a?(Regexp) ? options[:text] : Regexp.escape(options[:text])
|
||||
return false if not node.text.match(regexp)
|
||||
node.unsynchronized do
|
||||
if options[:text]
|
||||
regexp = options[:text].is_a?(Regexp) ? options[:text] : Regexp.escape(options[:text])
|
||||
return false if not node.text.match(regexp)
|
||||
end
|
||||
return false if options[:visible] and not node.visible?
|
||||
selector.custom_filters.each do |name, block|
|
||||
return false if options.has_key?(name) and not block.call(node, options[name])
|
||||
end
|
||||
true
|
||||
end
|
||||
return false if options[:visible] and not node.visible?
|
||||
selector.custom_filters.each do |name, block|
|
||||
return false if options.has_key?(name) and not block.call(node, options[name])
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
def matches_count?(count)
|
||||
|
|
Loading…
Reference in New Issue