Carrierwave + RSpec Test

I am testing that my file uploads are correct with models with RSpec by setting Model#filename = File.open(etc)

When my specs run, everything is great. But the files still remain in my public / uploads directory after testing is complete.

How do I get the files to be deleted at the end of the work along with the records?

Thank!

+3


source to share


2 answers


+3


source


One way is to remove them at the end of the test using an instance method that is called by the media. An example where your instance @user

and your carrier file attribute: avatar

would be:@user.remove_avatar!



0


source







All Articles