I am writing tests, and I am wondering if there is a way to change the current date during my test?
The fact is that I am testing the statistical functionality of the application, which is associated with the tracking model, which creates an instance every time an action is called (some actions are only tracked using the call "for interrogation only")
Therefore, I need to call these actions in different controllers at different points in time to verify that my analytic component is performing the correct calculations, but I did not find a way to implement change_current_time in the following code example:
test "login count" do
change_current_time(2.day.ago)
get "users/login/testuser/testpassword"
assert login_count(2.day.ago) == 1
change_current_time(1.day.ago)
get "users/login/testuser/testpassword"
get "users/login/testuser1/testpassword1"
assert login_count(1.day.ago) == 2
end
source
share