Use Timecop in Rails test environments
masterTo set a consistent time for your entire Rails test environment, you can use an after_initialize block in config/environments/test.rb. This allows you to build test data at a specific point in time.
# in config/environments/test.rb
config.after_initialize do
# Set Time.now to September 1, 2008 10:05:00 AM
t = Time.local(2008, 9, 1, 10, 5, 0)
Timecop.travel(t)
end