How to upload a file in a Rails Rspec request spec
问题 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' params = { file: Rack::Test::UploadedFile.new(path, 'application/pdf', true) } post v1_product_documents_path, params: params In the controller, I get a string "#Rack::Test::UploadedFile:0x0055b544479128>" instead of the actual file. The same code works in controller tests 回答1: try to use fixture_file_upload : fixture_file_upload or if you wanted to