TIL: Use Rails travel functions instead of timecop or time-warp1 min read til rails
If you were using
time-warp gems like me before, you will be happy to hear that Ruby on Rails provides its own
travel_to methods that allow you move in time and test time sensitive methods.
It’s great to see that you don’t need an external gem for this!
test 'creates a post in the past' do travel_to(5.days.ago) do @post = Post.create end assert_equal 5.days.ago, @post.created_at end
Read more at OmniRef.
Last modified: 20-Jan-23