Skip to content

Instantly share code, notes, and snippets.

@jnicklas
Created November 14, 2012 15:46
Show Gist options
  • Save jnicklas/d8da686061f0a59ffdf7 to your computer and use it in GitHub Desktop.
Save jnicklas/d8da686061f0a59ffdf7 to your computer and use it in GitHub Desktop.
def wait_until
require "timeout"
Timeout.timeout(Capybara.default_wait_time) do
sleep(0.1) until value = yield
value
end
end
@localhostdotdev
Copy link

require 'timeout'

class SystemTestCase < ActionDispatch::SystemTestCase
  def wait_until(time, &block)
    Timeout.timeout(time) { sleep(0.01) until block.call }
  end
end

wait_until(5.seconds) { page.has_content?("something") }

worked well for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment