DateTime.now.utc in fixtures

I have the following in my fixtures:

publish_date: <%= DateTime.now.utc - 1.day %>

But ‘DateTime.now.utc’ always evaluates to my system time. Does anyone
have any ideas?

Thanks,

Russell.

Russell Quinn wrote:

I have the following in my fixtures:

publish_date:<%= DateTime.now.utc - 1.day %>

But ‘DateTime.now.utc’ always evaluates to my system time. Does anyone
have any ideas?

You might not like it, but what about fixing the date?

Hi,

It might sound strange, but you usually stub Time.now
Read here: RSpec'ing with Time.now · devroom.io

Am 09.10.2010 um 02:20 schrieb Russell Quinn:

I have the following in my fixtures:

publish_date: <%= DateTime.now.utc - 1.day %>

But ‘DateTime.now.utc’ always evaluates to my system time. Does anyone
have any ideas?


Thomas R. “TomK32” Koll
just a geek trying to change the world
http://ananasblau.com || http://photostre.am || http://photolog.at

Great. Thanks for all the answers.

Russell.

On Tue, Oct 12, 2010 at 6:06 AM, Thomas R. Koll [email protected] wrote:

Hi,

It might sound strange, but you usually stub Time.now
Read here: RSpec'ing with Time.now · devroom.io

I used to do this myself even with Test::Unit
http://talklikeaduck.denhaven2.com/2007/07/18/time-flies-while-youre-having-fun-testing

More recently I’ve been using timecop

http://github.com/jtrupiano/timecop

It allows time to be either frozen or offset, and it stubs Time,
DateTime and Date to do the right thing.


Rick DeNatale

Help fund my talk at Ruby Conf 2010:http://pledgie.com/campaigns/13677
Blog: http://talklikeaduck.denhaven2.com/
Github: rubyredrick (Rick DeNatale) · GitHub
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale