Stubbing Time.now with RSpec
travel_to
from ActiveSupport
might serve the purpose better and might look as follows:
def test_date
travel_to Time.zone.parse('1970-01-01')
verify
travel_back
end
Depending on your version of RSpec you might want to use the newer syntax:
allow(Time).to receive(:now).and_return(@time_now)
See RSpec Mocks 3.3