would it have worked to use the active support TimeWithZone class in the spec since that’s what was…
Cole Hall
1

Thanks Cole. The spec was actually using TimeWithZone unwittingly via x.y.ago, while the model class is using Date via Date.today. From what I gather, Date uses the time zone of the system by default, whereas TimeWithZone will use the Rails zone config. And in our environment, the Rails zone config is being set to a random value for every test. So if the Profile class were changed to use Time.zone.today, I think the specs would’ve consistently passed. Instead, I changed the specs to use the Date class to match the class.

Thanks for taking the time to read and point this out. It could be a bit clearer, so I will edit when I have a moment.

Like what you read? Give Matt Ewell a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.