Merge pull request #7904 from E-L-T/add-rspec-retry-gem

test rspec retry gem
This commit is contained in:
LeSim 2023-08-29 13:30:03 +00:00 committed by GitHub
commit cd5d89336c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 2 deletions

View file

@ -106,6 +106,7 @@ group :test do
gem 'rack_session_access' gem 'rack_session_access'
gem 'rails-controller-testing' gem 'rails-controller-testing'
gem 'rspec_junit_formatter' gem 'rspec_junit_formatter'
gem 'rspec-retry'
gem 'selenium-devtools' gem 'selenium-devtools'
gem 'selenium-webdriver' gem 'selenium-webdriver'
gem 'shoulda-matchers', require: false gem 'shoulda-matchers', require: false

View file

@ -601,6 +601,8 @@ GEM
rspec-expectations (~> 3.11) rspec-expectations (~> 3.11)
rspec-mocks (~> 3.11) rspec-mocks (~> 3.11)
rspec-support (~> 3.11) rspec-support (~> 3.11)
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-support (3.12.0) rspec-support (3.12.0)
rspec_junit_formatter (0.4.1) rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0) rspec-core (>= 2, < 4, != 2.12.0)
@ -895,6 +897,7 @@ DEPENDENCIES
rexml rexml
rqrcode rqrcode
rspec-rails rspec-rails
rspec-retry
rspec_junit_formatter rspec_junit_formatter
rubocop rubocop
rubocop-performance rubocop-performance

View file

@ -16,6 +16,7 @@
# users commonly want. # users commonly want.
# #
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
require 'rspec/retry'
RSpec.configure do |config| RSpec.configure do |config|
config.filter_run_excluding disable: true config.filter_run_excluding disable: true
@ -59,3 +60,18 @@ RSpec.configure do |config|
end end
end 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

View file

@ -6,7 +6,7 @@ describe 'The user' do
let(:user_dossier) { user.dossiers.first } let(:user_dossier) { user.dossiers.first }
let!(:dossier_to_link) { create(:dossier) } 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) log_in(user, procedure)
fill_individual fill_individual

View file

@ -1,5 +1,5 @@
RSpec.shared_examples 'the user can edit the submitted demande' do 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) visit dossier_path(dossier)
expect(page).to have_current_path(dossier_path(dossier)) expect(page).to have_current_path(dossier_path(dossier))