module ActiveSupport::Testing::TimeHelpers
def freeze_time(&block)
end
User.create.created_at # => Sun, 09 Jul 2017 15:34:49 EST -05:00
sleep(1)
freeze_time do
Time.current # => Sun, 09 Jul 2017 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
Time.current # => Sun, 09 Jul 2017 15:34:49 EST -05:00
sleep(1)
freeze_time
Time.current # => Sun, 09 Jul 2017 15:34:49 EST -05:00
Calls +travel_to+ with +Time.now+.
def freeze_time(&block) travel_to Time.now, &block end