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
ruby-on-rails carrierwave


source to share


2 answers


https://github.com/jnicklas/carrierwave/wiki/How-to:-Cleanup-after-your-Rspec-tests



+3


source to share


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 to share







All Articles
Loading...
X
Show
Funny
Dev
Pics