I’m using Zonebie to randomize the time zone in my tests. It’s all working fine for my rspec tests, but I’m having an issue with my cucumber tests. It works by selecting a random timezone from ActiveSupport and setting Time.zone. I’ve followed the readme and added Zonebie.set_random_timezone to a support file features/support/zonbie.rb.
If I put a debugger statement in my steps, and I print Time.zone, it produces the correct randomized timezone. However, if I put a debuggger statement in a model function, it prints the default time zone as set up in my config/application.rb.
Is Time.zone being reset somewhere or does the change go out of scope somehow? Any ideas?
NB: I’m also using the Timecop gem if that has any implications.
I found a hack solution, which was to set
Time.zone_defaultinstead ofTime.zoneto the random timezone. I might send a pull request to the zonebie gem maintainers.