[rspec-users] RSpec Testing ActiveRecord config dependency.

James Byrne lists at ruby-forum.com
Mon Feb 9 17:23:21 EST 2009

James Byrne wrote:

> It seems that I am not overriding the AR:BASE.default_timezone setting 
> since, as far as I can tell, the values stored are the same whatever 
> value I set the default_tz to.

Well, after a very frustrating afternoon I have finally uncovered what 
is going on.  The problem I had is that I did not consider that 
AR::Base.default_timezone is used both in and out.  The display of 
datetime values retrieved via AR is adjusted according to the 
default_timezone setting at the time of retrieval and is not based on 
any TZ value stored in the database.

In my test setup I created rows with the tz value set to :utc and then 
:local.  However, when I ran the tests then I did not bother to reset 
the tz appropriately for each test. Thus the display of the data was 
adjusted by AR and confused the hell out of me.

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list