I had a look around for how to stub Time.now , #from_now , etc, and came across this, which was useful:
http://devblog.michaelgalero.com/2007/11/23/actioncontroller-rspec-stub-timenow/

Unfortunately, my situation is slightly different, and causes that solution to not be applicable. This is what I'm trying to spec:

def remember_me_for(time)
  remember_me_until time.from_now.utc
end

I thought this would work:

it 'should remember a user for a period of time' do
  user          = create_user
  one_week      = 1.week
  from_now      = 1.week.from_now
  from_now_utc  = 1.week.from_now.utc

  one_week.stub!(:from_now).and_return from_now
  from_now.stub!(:utc).and_return from_now_utc

  user.should_receive(:remember_me_until).with from_now_utc

  user.remember_me_for one_week
end

But that fails, referencing the stub on "one_week":

TypeError in 'User should remember a user for a period of time'
no virtual class for Fixnum

Any suggestions for how to solve this? Thanks!
Nick
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to