In my Rails 7 app I've got Capybara test which checks if downloading a PDF file works. The issue is that after a successful check, Capybara saves this file in the main path of the project. How do I delete this file right after the test?
it 'download invoice' do
payment = build :isor_payment, :with_pdf
stub_payment(payment)
login_as user
visit payment_path(payment.platform_payment_id)
click_on 'Download'
expect(page).to have_content I18n.t('payments.main_data_component.invoice_pdf')
end
After that test it will save me a pdf named payment-43523452.pdf.