From ad8e0a4cb60e33a30b04d5002e8851426e2bf554 Mon Sep 17 00:00:00 2001 From: Jonas Nicklas Date: Fri, 12 Aug 2011 14:38:42 +0200 Subject: [PATCH] Fix matchers to work with new async stuff --- lib/capybara.rb | 1 + lib/capybara/node/base.rb | 6 +----- lib/capybara/node/matchers.rb | 12 ++++++------ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/capybara.rb b/lib/capybara.rb index 65307f26..41cd32c3 100644 --- a/lib/capybara.rb +++ b/lib/capybara.rb @@ -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 diff --git a/lib/capybara/node/base.rb b/lib/capybara/node/base.rb index 3c2aba02..0926b135 100644 --- a/lib/capybara/node/base.rb +++ b/lib/capybara/node/base.rb @@ -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 diff --git a/lib/capybara/node/matchers.rb b/lib/capybara/node/matchers.rb index 3991985f..d1dee99c 100644 --- a/lib/capybara/node/matchers.rb +++ b/lib/capybara/node/matchers.rb @@ -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