search for: should_be_close_to

Displaying 1 result from an estimated 1 matches for "should_be_close_to".

2007 Jan 09
9
Date Approximation in Specs
...or an error tolerance. Is there any similar facility for dates? For example, say I have a custom class that handles date/time spans and I want to spec it: context "A DateRange span" do specify "should know when a week ago is :)" do d = DateRange.new d.last_week.should_be_close_to(1.week.ago, 24*60*60) end end The idea of should_be_close_to is to provide a tolerance. My class only is required to be accurate to the same day, and I want to express that in terms of "close_to" uncertainty. Is there a great baked-in way I''m missing? I have code to do...