Created
May 1, 2011 23:50
-
-
Save fizx/950999 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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