Time Travel by Rails
Rails have travel
, travel_to
, travel_back
Testing Helper Methods to travel in time and then test your app with exact dates and times.
include ActiveSupport::Testing::TimeHelpers
Time.current
=> Tue, 17 May 2016 12:31:52 UTC +00:00
travel_to Time.new(2004, 11, 24, 01, 04, 44)
Time.current
=> Wed, 24 Nov 2004 06:04:44 UTC +00:00
travel_back
Time.current
=> Tue, 17 May 2016 12:32:17 UTC +00:00
Another nice alternative is to use gems like:
Tweet