Spot on, Tom. Thanks.
For the (google) record:
Time.usec Returns just the number of microseconds for the given time.
ActiveRecord datetime attributes ignore microseconds (at least with
the SQLite adapter). In my case:
now.usec: 991786
@verified_user.session_key_updated_at.usec: 0
To fix the spec, don't use Time.now for the comparison:
it "sets the user's session_key_updated_at" do
now = Time.zone.local(2008, 9, 1, 12, 0, 0)
Timecop.freeze(now) do
verify_user
@verified_user.session_key_updated_at.should == now
end
end
Cheers,
/g
--
George Anderson
BenevolentCode LLC
O: (410) 461-7553
C: (410) 218-5185
[email protected]
On Fri, Aug 21, 2009 at 12:26 PM, Tom Stuart<[email protected]> wrote:
> On 21 Aug 2009, at 17:15, George Anderson wrote:
>>
>> expected: Fri, 21 Aug 2009 16:08:51 UTC +00:00,
>> got: Fri, 21 Aug 2009 16:08:51 UTC +00:00 (using ==)
>> They're identical, no?
>
> Not necessarily -- Time instances are microsecond precision, so two of them
> can differ (in microseconds) but have the same string representation (which
> only shows seconds). See what the #usec method gives you for each of the
> times.
>
> Cheers,
> -Tom
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users