module ActiveSupport::Testing::TimeHelpers

def travel(duration, &block)

Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
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

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

stubbing +Time.now+ and +Date.today+.
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