It simulates Time.now, DateTime.now and Date.today in a single call.
It is mainly used to run a time-sensitive test or to set the time for the test environment.
Here are some key features of "Timecop":
· Freeze time to a specific point.
· Travel back to a specific point in time, but allow time to continue moving forward from there.
· No dependencies, can be used with any ruby project
· Timecop api allows arguments to be passed into #freeze and #travel as one of the following: Time instance, DateTime instance, Date instance, individual arguments (year, month, day, hour, minute, second), a single integer argument that is interpreted as an offset in seconds from Time.now
· Nested calls to Timecop#travel and Timecop#freeze are supported — each block will maintain its interpretation of now.
What's New in This Release: [ read full changelog ]
· Fix various timezone-related issues. Notably, when traveling to a DateTime instance specified in a non-local timezone, convert provided DateTime instance to a local instance and return that from DateTime.now.
· Fix bug that would not allow Timecop to be used when Ruby’s ‘date’ library had not been previously loaded.
· Fix bug when traveling to a DateTime across a DST boundary that resulted in DateTime’s being off by an hour.
· Migrate argument parsing into Timecop::TimeStackItem to reduce the responsibility of the Timecop class.