1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Fix matchers to work with new async stuff

This commit is contained in:
Jonas Nicklas 2011-08-12 14:38:42 +02:00
parent dc1df7a742
commit ad8e0a4cb6
3 changed files with 8 additions and 11 deletions

View file

@ -5,6 +5,7 @@ module Capybara
class CapybaraError < StandardError; end
class DriverNotFoundError < CapybaraError; end
class ElementNotFound < CapybaraError; end
class ExpectationNotMet < ElementNotFound; end
class FileNotFound < CapybaraError; end
class UnselectNotAllowed < CapybaraError; end
class NotSupportedByDriverError < CapybaraError; end

View file

@ -45,7 +45,7 @@ module Capybara
begin
yield
rescue => e
raise e unless wait?
raise e unless driver.wait?
raise e unless (driver.respond_to?(:invalid_element_errors) and driver.invalid_element_errors.include?(e.class)) or e.is_a?(Capybara::ElementNotFound)
raise e if (Time.now - start_time) >= seconds
sleep(0.05)
@ -54,10 +54,6 @@ module Capybara
end
end
def wait?
driver.wait?
end
def driver
session.driver
end

View file

@ -34,7 +34,7 @@ module Capybara
#
def has_selector?(*args)
options = if args.last.is_a?(Hash) then args.last else {} end
wait_conditionally_until do
wait_until do
results = all(*args)
case
@ -50,9 +50,9 @@ module Capybara
options[:minimum].to_i <= results.size
else
results.size > 0
end
end or raise ExpectationNotMet
end
rescue Capybara::TimeoutError
rescue Capybara::ExpectationNotMet
return false
end
@ -66,7 +66,7 @@ module Capybara
#
def has_no_selector?(*args)
options = if args.last.is_a?(Hash) then args.last else {} end
wait_conditionally_until do
wait_until do
results = all(*args)
case
@ -82,9 +82,9 @@ module Capybara
not(options[:minimum].to_i <= results.size)
else
results.empty?
end
end or raise ExpectationNotMet
end
rescue Capybara::TimeoutError
rescue Capybara::ExpectationNotMet
return false
end