Created
April 5, 2024 21:55
-
-
Save sephraim/acaf9bd4f3b6edd828809a8bcdde10c7 to your computer and use it in GitHub Desktop.
[Stub date / time in Ruby / Rails RSpec tests]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before(:example) do | |
time = Time.new(2024, 3, 18, 17, 0, 0) | |
allow(Time).to receive(:now).and_return(time) | |
allow(Date).to receive(:today).and_return(time.to_date) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment