Skip to content

Instantly share code, notes, and snippets.

@sephraim
Created April 5, 2024 21:55
Show Gist options
  • Save sephraim/acaf9bd4f3b6edd828809a8bcdde10c7 to your computer and use it in GitHub Desktop.
Save sephraim/acaf9bd4f3b6edd828809a8bcdde10c7 to your computer and use it in GitHub Desktop.
[Stub date / time in Ruby / Rails RSpec tests]
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