On Tue, Feb 22, 2011 at 6:13 AM, James Martin <jimmymar...@gmail.com> wrote:
> I've recently been playing around with some code that re-runs a block until
> either the block returns a non-false value, or a timeout expires:
> https://gist.github.com/838520
> At first, I thought this was working, as I was just checking the timing of
> the examples when returning a true value, however, now it looks like sleep
> isn't being stubbed as I expect.
> In the final example, the output from RSpec shows the time taken is 1
> second, even though it's sleeping for at least the full 10 seconds specified
> in the first argument to #do_this.
> I can kind of imagine this not working at all, as the code relies on
> calculations between two instances of Time.now.
> Is there a better way to do this?
> I'm really keen to get away from the whole Time.now/sleep combination in my
> tests if possible. I was thinking that perhaps a virtual clock would be
> better, but then I've still got the sleep issue to deal with.
>
Eric Hodel recently blogged about this:
http://blog.segment7.net/2011/01/06/how-to-sleep-in-tests

Best,
Michael Guterl
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to