Rails carrierwave testing - how to remove file after test?

I am testing the carrierwave upload functionality using rspec and capybara. I have something like:

describe "attachment" do
    let(:local_path)  { "my/file/path" }
    before do
      attach_file('Attachment file', local_path)
      click_button "Save changes"       

    specify {user.attachment.should_not be_nil}
    it { should have_link('attachment', href: user.attachment_url) }

And this works great. The problem is that after testing the uploaded image remains in my public/uploads directory. How can I remove it after the test is done? I tried something like this:

after do

but it did not work.


You're not the only one having issues to delete the files in carrierwave.

I ended up doing:

user.remove_attachment = true

I got this tip reading this.

Need Your Help

Cmake test : was a library compiled/linked against libc++ or libstd++?

c++ cmake libstdc++ libc++

I am using cmake to manage my project that uses a third party library.

The method setActualDefaultRingtoneUri(Context, int, Uri) in the type RingtoneManager is not applicable for the arguments OnItemClickListener

android listview onitemclicklistener ringtone

I am making android application and I want when I click on list view item to find ID of clicked item, get resources and set that file as ringtone.However I get this error : The method