谁能建议为什么这个规范使用 Timecop 0.6.1 和 Ruby 2.0.0 失败?
(它使用 Timecop 0.4.5 和 Ruby 1.9.3 通过)
require 'timecop'
require 'spec_helper'
describe Class do
it "freezes time" do
Timecop.freeze Date.new(2012,7,1) do
expect(Date.today).to eq(Date.new 2012,7,1)
end
end
end
结果是:
$ rspec spec/models/time_cop_spec.rb
Failures:
1) Class freezes time
Failure/Error: expect(Date.today).to eq(Date.new 2012,7,1)
expected: Sun, 01 Jul 2012
got: Thu, 02 May 2013
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-Sun, 01 Jul 2012
+Thu, 02 May 2013