Instantly share code, notes, and snippets.

@jnicklas /wait_until.rb Secret
Created Nov 14, 2012

What would you like to do?
def wait_until
require "timeout"
Timeout.timeout(Capybara.default_wait_time) do
sleep(0.1) until value = yield

This comment has been minimized.

vishnun commented Nov 20, 2013

Give an example usage as well.


This comment has been minimized.

zacksiri commented Feb 3, 2014

wait_until { page.should have_content("something") } @vishnun


This comment has been minimized.

CoinAge commented Aug 5, 2014

After some research, found that wait_until has been removed from capybara 2.0.

In my case, I was able to wait for the page to have label text using the below:



This comment has been minimized.

djanowski commented Dec 4, 2014

@zacksiri That's exactly when you should not use wait_until :)



This comment has been minimized.

lisotton commented Jan 9, 2015

I liked the @CoinAge approach.


This comment has been minimized.

camhine commented Mar 4, 2015

This snippet of code has worked really well for us. Ideally we would use the waiting_rspec_matchers gem: But we're on an older version of rspec so it isn't an option.

Here is the code we use to wait until the 'Content-Disposition' response header is present and then check that it is expected value.

wait_until { page.response_headers.include?('Content-Disposition') }
page.response_headers['Content-Disposition'].should include("expected value")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment