Created
January 29, 2013 23:21
-
-
Save zekus/4668940 to your computer and use it in GitHub Desktop.
add synchronised has_path? to capybara
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Capybara | |
class Session | |
def has_path?(path) | |
synchronize do | |
current_path == path or raise Capybara::ExpectationNotMet | |
end | |
end | |
def synchronize(seconds=Capybara.default_wait_time) | |
start_time = Time.now | |
begin | |
yield | |
rescue => e | |
raise e if (Time.now - start_time) >= seconds | |
sleep(0.05) | |
retry | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment