我在努力拖延时间.现在在RSpec中,如下所示:
it "should set the date to the current date" do
@time_now = Time.now
Time.stub!(:now).and_return(@time_now)
@thing.capture_item("description")
expect(@thing.items[0].date_captured).to eq(@time_now)
end
执行此操作时,我会遇到以下错误:
Failure/Error: Time.stub!(:now).and_return(@time_now)
NoMethodError:
undefined method `stub!' for Time:Class
知道为什么会这样吗?