Skip to content

Instantly share code, notes, and snippets.

@zekus
Created January 29, 2013 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zekus/4668940 to your computer and use it in GitHub Desktop.
Save zekus/4668940 to your computer and use it in GitHub Desktop.
add synchronised has_path? to capybara
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