[rspec-users] stubbing Time.zone.now for model tests fails for Rails 2.3.1

Bart Zonneveld zuperinfinite at gmail.com
Sat Mar 14 07:01:11 EDT 2009

On 14 mrt 2009, at 11:27, Bart Zonneveld wrote:

> On 12 mrt 2009, at 04:22, Stephen Eley wrote:
>> On Wed, Mar 11, 2009 at 1:40 PM, David Schmidt <davids at tower- 
>> mt.com> wrote:
>>> Has anyone else run into this problem and come up with a solution  
>>> to getting
>>> a fixed time back from Time.zone.now?
>> This plugin has worked very well for me:
>> http://github.com/notahat/time_travel/tree/master
> Great! This is exactly what I need for a project I'm working on.
> However, I need to run all my tests on a specific date. I'm doing  
> stuff which is week-based, so "Tomorrow" and "Next week" are always  
> different, and therefore I'd like to set it to a specific date for  
> all my tests.
> Any idea how to hook this into a Before-hook in Cucumber perhaps?

While I was doing the dishes, I came up with the following:

World do |world|
   at_time(Time.utc(2009,1,1)) do

Unfortunately, this doesn't work :(...
Any ideas?

thanks a bunch,

More information about the rspec-users mailing list