From d9a228e5ec199a66948feefc288acb4e580d10ff Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Mon, 31 Aug 2020 17:47:41 +0100 Subject: [PATCH] Replace before and after hook with an around hook --- .../enterprises/terms_and_conditions_spec.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/features/admin/enterprises/terms_and_conditions_spec.rb b/spec/features/admin/enterprises/terms_and_conditions_spec.rb index d13893c0dc..ced7c5deea 100644 --- a/spec/features/admin/enterprises/terms_and_conditions_spec.rb +++ b/spec/features/admin/enterprises/terms_and_conditions_spec.rb @@ -26,15 +26,21 @@ feature "Uploading Terms and Conditions PDF" do let(:white_pdf_file_name) { Rails.root.join("app/assets/images/logo-white.pdf") } let(:black_pdf_file_name) { Rails.root.join("app/assets/images/logo-black.pdf") } - before do + around do |example| # Create fake PDFs from PNG images FileUtils.cp(Rails.root.join("app/assets/images/logo-white.png"), white_pdf_file_name) FileUtils.cp(Rails.root.join("app/assets/images/logo-black.png"), black_pdf_file_name) - go_to_business_details + example.run + + # Delete fake PDFs + FileUtils.rm_f(white_pdf_file_name) + FileUtils.rm_f(black_pdf_file_name) end scenario "uploading terms and conditions" do + go_to_business_details + # Add PDF attach_file "enterprise[terms_and_conditions]", white_pdf_file_name click_button "Update" @@ -53,12 +59,6 @@ feature "Uploading Terms and Conditions PDF" do go_to_business_details expect(page).to have_selector("a[href*='logo-black.pdf']") end - - after do - # Delete fake PDFs - FileUtils.rm_f(white_pdf_file_name) - FileUtils.rm_f(black_pdf_file_name) - end end end end