Flowdock
method

freeze_time

Importance_1
v5.2.3 - Show latest stable - 0 notes - Class: TimeHelpers
freeze_time(&block) public

Calls travel_to with Time.now.

Time.current # => Sun, 09 Jul 2017 15:34:49 EST -05:00
freeze_time
sleep(1)
Time.current # => Sun, 09 Jul 2017 15:34:49 EST -05:00

This method also accepts a block, which will return the current time back to its original state at the end of the block:

Time.current # => Sun, 09 Jul 2017 15:34:49 EST -05:00
freeze_time do
  sleep(1)
  User.create.created_at # => Sun, 09 Jul 2017 15:34:49 EST -05:00
end
Time.current # => Sun, 09 Jul 2017 15:34:50 EST -05:00
Show source
Register or log in to add new notes.