Testing
Use rspec with Rails
Time Travel
RSpec.configure do |config|
# ... your other settings
config.include ActiveSupport::Testing::TimeHelpers
endfreeze_time do
time1 = Time.now
sleep 2
time2 = Time.now
time1 == time2 # => true
end
Time.now # => 2019-07-24 22:56:29 +0200
travel 1.day do
p Time.now # => 2019-07-25 22:56:29 +0200
end
travel_to Time.zone.local(2019, 2, 2, 9, 9, 0) do
p Time.now # => Left as an exercise to the reader
endLast updated