|
|
|
|
|
by dissident_coder
917 days ago
|
|
As a Ruby/Rails developer, time mocking is awesome. It's built right into rails or you can use Timecop and it's just as simple as adding: around { |example| Timecop.freeze("2023-12-20T12:00:00Z".to_datetime) { ex.run } }
or around { |example| travel_to("2023-12-20T12:00:00Z".to_datetime) { ex.run } }
as setup hooks to your tests and it stubs all of the relevant datetime helpers for you for each test case and properly restores everything between tests. |
|