I'm working on unit tests for my Rails app and have run into the following problem.
I have an Event model with a fixture that boils down to:
concert:
name: Wallflowers
start_at: <%= DateTime.new(1999) %>
In my unit test, I have the following assertion:
assert_equal DateTime.new(1999), events(:concert).start_at
The test fails, with the following message:
<Fri, 01 Jan 1999 00:00:00 +0000> expected but was
<Thu, 31 Dec 1998 19:00:00 UTC +00:00>.
I can't figure out why its getting adjusted. The offset of the incorrect time is 5 hours, which is my local offset.
Other info that might be relevant:
- The problem only occurs while testing--I don't have any problems in development
- environment.rb contains config.time_zone = 'UTC'
- The test works if I use Date.new instead of DateTime.new, but I need to use DateTime
What am I missing? Appreciate the help.