module ActiveSupport::Testing::TimeHelpers
def travel(duration, &block)
end
User.create.created_at # => Sun, 10 Nov 2013 15:34:49 EST -05:00
travel 1.day do
Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
state at the end of the block:
This method also accepts a block, which will return the current time back to its original
DateTime.current # => Sun, 10 Nov 2013 15:34:49 -0500
Date.current # => Sun, 10 Nov 2013
Time.current # => Sun, 10 Nov 2013 15:34:49 EST -05:00
travel 1.day
Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
at the end of the test.
stubbing +Time.now+, +Date.today+, and +DateTime.now+. The stubs are automatically removed
Changes current time to the time in the future or in the past by a given time difference by
def travel(duration, &block) travel_to Time.now + duration, &block end