ActiveSupport includes Timecop-like helpers
ActiveSupport (since 4.1) includes test helpers to manipulate time, just like the Timecop gem:
To travel a relative amount of time, use
To travel to a specific moment in time, use
To freeze a specific time, use
All those methods may also receive a block to call and restore time afterwards. If you don't provide a block, you must call
unfreeze_time once you are done.
Note that we love Timecop and that it may be better suited for some use cases (for example, it includes
Timecop.scale and a
Timecop.safe_mode configuration setting), but for most projects you actually may not need Timecop.