【发布时间】:2019-07-30 17:37:45
【问题描述】:
使用 Rails 5.2.3。在 Rspec 中出现错误。我认为错误是因为我输入错误或误用了 expect 方法。
Failure/Error: expect(SongsController.stub).to receive(:send_file)
ArgumentError: wrong number of arguments (given 0, expected 1..2)
来自控制器的代码在浏览器中运行。
send_file "amazing_grace.zip", :filename => "amazing_grace.zip", :url_based_filename => false, :type => "application/zip"
测试代码如下:
require 'rails_helper'
RSpec.describe 'Songs features' do
describe 'viewing the index' do
it 'downloads zip file from amazon' do
expect(SongsController.stub).to receive(:send_file)
visit('/songs/get_zip/1')
end
end
end
如何更正期望方法,不再出现此错误?
【问题讨论】:
标签: rspec ruby-on-rails-5 rspec-rails