I just released version 0.2.0 of Timecop this evening (morning).
The primary feature added was the distinction between “freezing” and “rebasing” time. In 0.1.0,
Timecop.travel would actually freeze time. This is no longer the case. Rather, a time offset will be calculated, and a running clock is simulated by always offsetting the time returned by Time.now (and friends) by the original offset.
(Note that time can still be frozen with
To update a previous version:
<code>sudo gem update timecop</code>
To install for the first time:
<code>sudo gem install timecop</code>
The new feature set allows us to avoid the following common pitfalls that were present in 0.1.0.
- In rails, if you had set up a time mock in the development environment, then every time you invoked
script/generate migration(and others), the generator would read your mocked instance of Time.now, and use that date for the migration name.
- Any benchmarking/timing code executed within the yielded block would always return times of 0 seconds. This was due to time being frozen.
The other major change to the API was the deprecating of Timecop.unset_all in favor or Timecop.return.
This update also vastly improves the rdoc, making the public API much more accessible. The Timecop class has particularly thorough documentation.
For a more complete description of the gem, please refer to the introductory blog post.