[rspec-users] Date Approximation in Specs

David Chelimsky dchelimsky at gmail.com
Tue Jan 9 19:45:08 EST 2007


On 1/9/07, s.ross <cwdinfo at gmail.com> wrote:
> The floating-point expectations allow for 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 this in Test::Unit that I could port over if need
> be but I'd rather not if something better already exists.

Doesn't exist yet. Feel free to add a feature request:

http://rubyforge.org/tracker/?group_id=797

> Thanks,
>
> Steve
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list