Skip to content

Instantly share code, notes, and snippets.

@joliss
Created August 21, 2012 13:23
  • Star 12 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save joliss/10c41024510ee9f235e0 to your computer and use it in GitHub Desktop.
Simple wait_for_* helper method for Capybara tests
# spec/support/capybara_helpers.rb
module CapybaraHelpers
def wait_for_whizboo
start = Time.now
while true
break if [check for whizboo here, e.g. with page.evaluate_script]
if Time.now > start + 5.seconds
fail "Whizboo didn't happen."
end
sleep 0.1
end
end
end
RSpec.configure do |config|
config.include CapybaraHelpers, type: :request
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment