Below is my testing code for uploading file.
describe \"file process\" do
before(:each) do
# debugger
@file = fixture_file_upload(\'test.csv\', \'text/csv
This is how I did it with Rails 6
, RSpec
and Rack::Test::UploadedFile
describe 'POST /create' do
it 'responds with success' do
post :create, params: {
company: {
logo: Rack::Test::UploadedFile.new("#{Rails.root}/spec/fixtures/test-pic.png"),
name: 'test'
}
}
expect(response).to be_successful
end
end
DO NOT include ActionDispatch::TestProcess or any other code unless you're sure about what you're including.