Forum: RSpec daylight savings time difference with rspec?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Adb1ac1499ccd80fe450d4295d818450?d=identicon&s=25 Harry Bishop (hrbishop)
on 2008-10-26 22:45
Hi all,
I wanted to check this with you.  I have an rspec example that checks
the correct expiration date set on an object.  The expiration is set in
the model with

expires_on = Time.now + next_duration[phase]

where next_duration can either be in units of seconds or n.days (should
be the same thing). n can be 3, 7, 25, or 30 days.

in my example I check an interval because the two events are not
simultaneous between when the model calls Time.now and when the rspec
example calls it:

    rhs = expires_on < (Time.now + (n +200))
    lhs = expires_on > (Time.now + (n -200))
    (rhs && lhs).should be_true

I find that if n takes the expires_on across the daylight savings time
change then the model and rspec are off by 1 hour.

Why is there a difference? Are Rails and RSpec referencing different
time objects?

Thanks for your help,
Harry
This topic is locked and can not be replied to.