Re: [rspec-users] What is the pattern for testing a time argument using argument matcher

2012-01-26 Thread Justin Ko
On Jan 26, 2012, at 8:44 AM, Yi Wen wrote: > Say I do: > > ```ruby > object.method 5.days.ago > ``` > > In the test I want to test using should_receive like: > > ```ruby > object.should_receive(:method).with(5.days.ago) > ``` > > This will fail since two time objects aren't exact the same. >

Re: [rspec-users] What is the pattern for testing a time argument using argument matcher

2012-01-26 Thread Morten Møller Riis
You can use things like Timecop. I prefer to just stub Time.now: timestamp = Time.now.to_i Time.stub(:now).returns(Time.at(timestamp)) Best regards Morten Møller Riis On Jan 26, 2012, at 4:44 PM, Yi Wen wrote: > Say I do: > > ```ruby > object.method 5.days.ago > ``` > > In the test I wan

[rspec-users] What is the pattern for testing a time argument using argument matcher

2012-01-26 Thread Yi Wen
Say I do: ```ruby object.method 5.days.ago ``` In the test I want to test using should_receive like: ```ruby object.should_receive(:method).with(5.days.ago) ``` This will fail since two time objects aren't exact the same. What is the general pattern for testing this in rspec? Thanks _