Skip to content

Instantly share code, notes, and snippets.

@fizx
Created May 1, 2011 23:50
Show Gist options
  • Select an option

  • Save fizx/950999 to your computer and use it in GitHub Desktop.

Select an option

Save fizx/950999 to your computer and use it in GitHub Desktop.
module Kernel
def eventually(timeout = 1.0, start = Time.now, exception = nil, &block)
throw exception || Timeout::Error if Time.now > (start + timeout)
begin
return true if block.call
rescue RSpec::Expectations::ExpectationNotMetError => exception
EM.next_tick {
eventually(timeout, start, exception, &block)
}
end
end
end
# Usage:
eventually { something.should == true }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment