Look at this code Rails FactoryGirl definition for a regular user class
FactoryGirl.define do factory :user do first_name "John" last_name "Doe" subscription_end_date Date.parse("2019-01-01") end end
Does not look harmful. This is a base model. When your other spec files start using it, everything will work fine when you evaluate the
subscription_end_date with other fields, but, exactly after
2019-01-01, on 2nd Jan 2019, the tests dependent on this value will start failing.
Anything that is hard coded when tested with relative time like, before/after (based on when the test is running) will start failing.
Either use all relative dates or all absolute dates.
Time.zone.now is relative unless you perform a
timecop.freeze before hand.
Happy hacking!comments powered by Disqus