How to run a spec / test when there is a time latency or lag involved

Public, Testing / TDD, Gems


Created: Oct 28, 2014     Updated: Oct 28, 2014

For example, if something is supposed to automatically delete every 7 days, how do you test for that?

Two ideas

  1. You can manually changed the created_at data in the database to back date an item, simulating it was created 7 days ago

  2. There is a gem called timecop that can simulate that time has elapsed or is frozen