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. Thanks, James.
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users