RSpec kills files after dialing is complete

In my rSpec tests, I check the ability to clip to upload photos to my system and save them with this user.

This is great, however, when my tests end, I have all these additional files on my system. How to automatically remove this after completing my test suite.

thank you microphone

+8
ruby-on-rails-3 rspec-rails paperclip
source share
2 answers

I did not use Paperclip, but I assume that these files are stored in a somewhat permanent place, for example (random example) tmp / paperclip / photos / .

If in this case in your spec_helper you can add:

config.after(:suite) do # or :each or :all Dir["#{Rails.root}/tmp/paperclip/**/*"].each do |file| File.delete(file) end end 
+5
source share

It's easier to just delete the entire test directory. It is also slightly less overhead and easier to read.

 # spec_helper.rb config.after(:suite) do FileUtils.rm_rf(Dir["#{Rails.root}/public/system/test"]) end 
+9
source share

All Articles