travel(duration, &block)
Instance Public methods
Changes current time to the time in the future or in the past by a given
time difference by stubbing Time.now
and
Date.today
.
1 2 3 4 | Time .current # => Sat, 09 Nov 2013 15:34:49 EST -05:00 travel 1 .day Time .current # => Sun, 10 Nov 2013 15:34:49 EST -05:00 Date.current # => Sun, 10 Nov 2013 |
This method also accepts a block, which will return the current time back to its original state at the end of the block:
1 2 3 4 5 | Time .current # => Sat, 09 Nov 2013 15:34:49 EST -05:00 travel 1 .day do User.create.created_at # => Sun, 10 Nov 2013 15:34:49 EST -05:00 end Time .current # => Sat, 09 Nov 2013 15:34:49 EST -05:00 |
Please login to continue.