Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A Rails plugin that makes it easy to write tests or specs for time-dependent code
Ruby
Tree: 2c7350ef2e

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
coverage
lib
spec
MIT-LICENSE
README
Rakefile
init.rb

README

= TimeTravel

This lets you set the current time in your tests or specs, so you can do
things like:

  at_time("1 April 2020 2:32 UTC") do
    # some fancy code
  end
  
Inside the block, Time.now will return the time you provide. The time will
be restored to normal system time when the block exits, even if it throws
an exception.

The at_time function can take a Time object, or a string to parse into a time.

TimeTravel is only loaded in the Rails test environment. If you need it in
your development environment, just require 'time_travel'.
Something went wrong with that request. Please try again.