Time Traveling Servers

Ever wonder how you could start your server in a different time, like say 2 days ago.  The QA team was struggling with this for a while until my coworker came up with this ingenious way of using Timecop. In your environment.rb file in rails, add in this:

days = ENV['TIMECOP_DAYS'].nil? ? 0 : ENV['TIMECOP_DAYS'].to_i
minutes = ENV['TIMECOP_MINUTES'].nil? ? 0 : ENV['TIMECOP_MINUTES'].to_i
Timecop.travel Time.now + days.days
Timecop.travel Time.now + minutes.minutes

With that in your environment file, you can start rails server like this:

TIMECOP_DAYS=-1 rails server

Now for all intents and purposes it looks like you are exactly 24 hours ago.