Mocha seems a great way to stub Time.now for testing expiration dates, etc.
with rspec. I can get it to stub a single time easily:
but what I'd really like to do is do that multiple times during a test:
specify "with an expired cookie should return nil"
Time.stubs(:now).returns(Time.parse("Jan 1 2001"))
cookie = louie.remember_me
Time.stubs(:now).returns(Time.parse("Oct 1 2001"))
However, only the first stubs call has any effect. I've tried stubbing it
to a FakeTime object:
but it only looks at the value of FakeTime.now when the stub is created.
Is there a way using Mocha/Stubba to stub a routine and have it call
another for the return value? I've tried creating procs/lambdas, but I
must be doing something wrong - I get an infinite recursion.