rspec - Rails 4 Paperclip FactoryGirl file uploading -
i have factorygirl :product factory uses fixture_file_upload set image , paperclip attachment. image { fixture_file_upload "#{rails.root}/spec/fixtures/images/product.png", 'image/png' } fixture_file_upload works fine, but every time test creates new product using factory, paperclip creates new file in publicproducts/<id>/original.png . this issue. . filling folder publicproducts on each test run not acceptable. the first workaround can think of solution mentioned in https://github.com/carrierwaveuploader/carrierwave/wiki/how-to:-cleanup-after-your-rspec-tests have solved problem in way? the solution, mentioned deep to: specify paperclip in test environment should upload files folder test_uploads , modify factory_girl factories upload fixture ex. spec/fixtures/images/filename.extension , add after cleanup block in rails_helper.rb in code: config/environments/test.rb ... config.paperclip_defaults = { path: ':r...