From 3f1309011a92f75e1b0adadbfad14884a22287e7 Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Mon, 10 Oct 2022 09:41:33 +0200 Subject: [PATCH] test gem --- Gemfile | 1 + Gemfile.lock | 3 +++ spec/spec_helper.rb | 16 ++++++++++++++++ spec/system/users/brouillon_spec.rb | 2 +- spec/system/users/dossier_shared_examples.rb | 2 +- 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 35dd58cd4..25829f8ee 100644 --- a/Gemfile +++ b/Gemfile @@ -106,6 +106,7 @@ group :test do gem 'rack_session_access' gem 'rails-controller-testing' gem 'rspec_junit_formatter' + gem 'rspec-retry' gem 'selenium-devtools' gem 'selenium-webdriver' gem 'shoulda-matchers', require: false diff --git a/Gemfile.lock b/Gemfile.lock index b0785402f..effd347e0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -601,6 +601,8 @@ GEM rspec-expectations (~> 3.11) rspec-mocks (~> 3.11) rspec-support (~> 3.11) + rspec-retry (0.6.2) + rspec-core (> 3.3) rspec-support (3.12.0) rspec_junit_formatter (0.4.1) rspec-core (>= 2, < 4, != 2.12.0) @@ -895,6 +897,7 @@ DEPENDENCIES rexml rqrcode rspec-rails + rspec-retry rspec_junit_formatter rubocop rubocop-performance diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b0478d438..9a04c8697 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -16,6 +16,7 @@ # users commonly want. # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +require 'rspec/retry' RSpec.configure do |config| config.filter_run_excluding disable: true @@ -59,3 +60,18 @@ RSpec.configure do |config| end end end + +RSpec.configure do |config| + # show retry status in spec process + config.verbose_retry = true + # show exception that triggers a retry if verbose_retry is set to true + config.display_try_failure_messages = true + + # callback to be run between retries + config.retry_callback = proc do |ex| + # run some additional clean up task - can be filtered by example metadata + if ex.metadata[:js] + Capybara.reset! + end + end +end diff --git a/spec/system/users/brouillon_spec.rb b/spec/system/users/brouillon_spec.rb index 1d7182724..2a3699083 100644 --- a/spec/system/users/brouillon_spec.rb +++ b/spec/system/users/brouillon_spec.rb @@ -6,7 +6,7 @@ describe 'The user' do let(:user_dossier) { user.dossiers.first } let!(:dossier_to_link) { create(:dossier) } - scenario 'fill a dossier', js: true do + scenario 'fill a dossier', js: true, retry: 3 do log_in(user, procedure) fill_individual diff --git a/spec/system/users/dossier_shared_examples.rb b/spec/system/users/dossier_shared_examples.rb index 67910e147..638a9ae96 100644 --- a/spec/system/users/dossier_shared_examples.rb +++ b/spec/system/users/dossier_shared_examples.rb @@ -1,5 +1,5 @@ RSpec.shared_examples 'the user can edit the submitted demande' do - scenario js: true do + scenario js: true, retry: 3 do visit dossier_path(dossier) expect(page).to have_current_path(dossier_path(dossier))