定义 我有以下工厂: FactoryGirl.define do
factory :task do
due_date 7.days.from_now
end
end
在我的规格,我以这种方式使用时空特警: before do
Timecop.freeze(Time.parse("Oct 5 2015"))
end
Time.now和Date.to
我有一个大的rails测试套件,我只用了一次timecop。 it "should not include votes from today" do
assert_equal 8, @answer.todays_score
end
it "should include today's votes tomorrow" do
Timecop.travel(Date.today
我试图总结Timecop围绕shared_example规范我写 describe "timecop wrapping shared example" do
Timecop.freeze(1.day.ago) do
it_behaves_like "a shared example i would like to test using timecop"
end
e
任何人都可以提出为什么此规范使用Timecop 0.6.1和Ruby 2.0.0失败吗? (它通过使用时空特警0.4.5和1.9.3的Ruby) require 'timecop'
require 'spec_helper'
describe Class do
it "freezes time" do
Timecop.freeze Date.new(2012,7,1) d