From 2f860236a547420daf15c6cc6689e4c0e08c82a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 29 Aug 2018 23:42:09 +0200 Subject: [PATCH] Reset page driver after every spec using it There were some issues because some specs directly used the driver but didn't reset it after the test. --- spec/features/home_spec.rb | 4 ++-- spec/spec_helper.rb | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/features/home_spec.rb b/spec/features/home_spec.rb index 7f90f54c1..c24066e79 100644 --- a/spec/features/home_spec.rb +++ b/spec/features/home_spec.rb @@ -112,7 +112,7 @@ feature "Home" do end feature 'IE alert' do - scenario 'IE visitors are presented with an alert until they close it' do + scenario 'IE visitors are presented with an alert until they close it', :page_driver do # Selenium API does not include page request/response inspection methods # so we must use Capybara::RackTest driver to set the browser's headers Capybara.current_session.driver.header( @@ -133,7 +133,7 @@ feature "Home" do expect(page.driver.request.cookies['ie_alert_closed']).to eq('true') end - scenario 'non-IE visitors are not bothered with IE alerts' do + scenario 'non-IE visitors are not bothered with IE alerts', :page_driver do visit root_path expect(page).not_to have_xpath(ie_alert_box_xpath, visible: false) expect(page.driver.request.cookies['ie_alert_closed']).to be_nil diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d845190ed..98ffd6f31 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -60,6 +60,10 @@ RSpec.configure do |config| end end + config.after(:each, :page_driver) do + page.driver.reset! + end + config.before(:each, type: :feature) do Capybara.reset_sessions! end