小编han*_*hee的帖子

fixture_file_upload有{file}不存在错误

以下是我上传文件的测试代码.

describe "file process" do
 before(:each) do
   # debugger
   @file = fixture_file_upload('test.csv', 'text/csv')
 end

 it "should be able to upload file" do
  post :upload_csv, :upload => @file
  response.should be_success
 end
end
Run Code Online (Sandbox Code Playgroud)

但是,当我运行rspec规范时,它会产生下面的错误

Failure/Error: @file = fixture_file_upload('test.csv', 'text/csv')
 RuntimeError:
   test.csv file does not exist
 # ./spec/controllers/quotation_controller_spec.rb:29:in `block (3 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud)

我搜索了很多地方,但我仍然无法找出背后的原因.任何的想法?

rspec ruby-on-rails

17
推荐指数
3
解决办法
1万
查看次数

标签 统计

rspec ×1

ruby-on-rails ×1