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 1/3] 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 From b153f5f902b55abd4e04a85ce3b7259ec9b5fad4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 29 Aug 2018 23:45:46 +0200 Subject: [PATCH 2/3] Remove redundant Capybara actions Resetting sessions and driver is automatically done by requiring 'capybara/rspec', as shown by the (lack of) that configuration for RSpec in the Capybara README, manual testing of those settings, and Capybara's code itself. --- spec/spec_helper.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 98ffd6f31..ffa111bfb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -64,10 +64,6 @@ RSpec.configure do |config| page.driver.reset! end - config.before(:each, type: :feature) do - Capybara.reset_sessions! - end - config.before do DatabaseCleaner.start end From dc65c0cdb144ab250fa868586d9ffbd65d0990a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 30 Nov 2018 14:06:33 +0100 Subject: [PATCH 3/3] Fix space differences with Madrid's fork --- spec/spec_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ffa111bfb..c7b723b4d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,7 +6,7 @@ require 'knapsack_pro' Dir["./spec/models/concerns/*.rb"].each { |f| require f } Dir["./spec/support/**/*.rb"].sort.each { |f| require f } -Dir["./spec/shared/**/*.rb"].sort.each { |f| require f } +Dir["./spec/shared/**/*.rb"].sort.each { |f| require f } RSpec.configure do |config| config.use_transactional_fixtures = false @@ -19,6 +19,7 @@ RSpec.configure do |config| config.include(EmailSpec::Matchers) config.include(CommonActions) config.include(ActiveSupport::Testing::TimeHelpers) + config.before(:suite) do DatabaseCleaner.clean_with :truncation end