[rspec-users] Date comparisons
rick.denatale at gmail.com
Sat May 3 13:51:43 EDT 2008
On Sat, May 3, 2008 at 12:17 PM, Joe Van Dyk <joe at pinkpucker.net> wrote:
> I occasionally get this error:
> 'A puzzle once featured, should no longer be nominated' FAILED
> expected: Sun May 04 09:10:26 -0700 2008,
> got: Sun May 04 09:10:26 -0700 2008 (using ==)
> So, the dates looks the same to me. Any ideas for how to debug?
Just because too objects have the same to_s representation don't mean
they are equal:
Are these, perhaps times rather than dates?
irb(main):001:0> Time.now == Time.now
irb(main):002:0> a, b = Time.now, Time.now
=> [Sat May 03 12:23:12 -0400 2008, Sat May 03 12:23:12 -0400 2008]
irb(main):003:0> a == b
This is a similar issue to Floats where there's more precision than
the exernal representation shows.
My blog on Ruby
More information about the rspec-users