How to upload a file in a Rails Rspec request spec

前端 未结 5 2190
没有蜡笔的小新
没有蜡笔的小新 2021-02-19 03:20

I want to test uploading a file in a Rails Rspec request test. I\'m using Paperclip for asset storage.

I\'ve tried:

path = \'path/to/fixture_file\'
para         


        
5条回答
  •  天涯浪人
    2021-02-19 03:47

    try to use fixture_file_upload: fixture_file_upload

    or if you wanted to use this in a factory

     Rack::Test::UploadedFile.new(File.open(File.join(Rails.root, '/spec/fixtures/images/bob-weir.jpg')))
    

提交回复
热议问题