【发布时间】:2015-02-06 11:50:24
【问题描述】:
我有一个方法可以发送明天的日期(1.date.from_now)。我正在我的规范中测试相同的方法。谁能告诉我如何存根那个日期。
如果我通过 1.date.from 现在。出现以下错误。
<S3Client (class)> received :upload_csv_by_path with unexpected arguments
expected: ("/home/projects/sh/tmp/test_exporter.csv", nil, {:expires=>Sat, 07 Feb 2015 11:36:39 UTC +00:00})
got: ("/home/projects/sh/tmp/test_exporter.csv", nil, {:expires=>Sat, 07 Feb 2015 11:36:39 UTC +00:00})
下面是我的方法
S3Client.upload_csv_by_path(file_name, nil, expires: 1.day.from_now)
这是我的规格,
S3Client.should_receive(:upload_csv_by_path).with("#{Rails.root}/tmp/scalar_test_exporter.csv", nil, expires: 1.day.from_now)
谁能告诉我如何解决这个问题
【问题讨论】:
-
看宝石timecop
标签: rspec-rails ruby-on-rails-4.1