[rspec-users] "lambda Should Change" Behavior Failing When Checking Time

Ashley Moran ashley.moran at patchspace.co.uk
Sun Nov 8 09:28:19 EST 2009

On Nov 08, 2009, at 10:39 am, Rodrigo Rosenfeld Rosas wrote:

> @post.published_at.should be_nil
> @post.publish!
> (Time.now - @post.published_at).should have_at_most(1).second

FWIW, this is what I do too, although I normally use "should <" or  
"be_close", but the idea is the same.  You only need to worry about  
more accuracy than that if it's time-critical.

Also, I've found meddling with Time breaks RSpec's timing - don't know  
if that's still the case.  For times when I really care about timing,  
I've made a Clock class, and have everything use that, instead of Time  



More information about the rspec-users mailing list