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 directly.

Ashley

--
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to