sonic-pi

https://github.com/sonic-pi-net/sonic-pi

C++

Code. Music. Live.

ActiveSupport::Testing::TimeHelpers#travel

Changes current time to the time in the future or in the past by a given time difference by
stubbing +Time.now+ and +Date.today+.

  Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
  travel 1.day
  Time.current # => Sun, 10 Nov 2013 15:34:49 EST -05:00
  Date.current # => Sun, 10 Nov 2013

This method also accepts a block, which will return the current time back to its original
state at the end of the block:

  Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
  travel 1.day do
    User.create.created_at # => Sun, 10 Nov 2013 15:34:49 EST -05:00
  end
  Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00

Source | Google | Stack overflow

Edit

git clone [email protected]:sonic-pi-net/sonic-pi.git

cd sonic-pi

open app/server/ruby/vendor/activesupport-7.0.6/lib/active_support/testing/time_helpers.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-ActiveSupport--Testing--TimeHelpers-travel-for-pr


# Commit to git

git add app/server/ruby/vendor/activesupport-7.0.6/lib/active_support/testing/time_helpers.rbgit commit -m "better docs for ActiveSupport::Testing::TimeHelpers#travel"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-ActiveSupport--Testing--TimeHelpers-travel-for-pr

hub pull-request


# Celebrate!