From e591851b799a01b559275e94e6317e8b8b24b354 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Fri, 10 Nov 2023 14:24:28 +0100 Subject: [PATCH] test: fix warning about classes already defined by another spec --- spec/support/shared_examples_for_jobs.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/spec/support/shared_examples_for_jobs.rb b/spec/support/shared_examples_for_jobs.rb index f30a67769..334307369 100644 --- a/spec/support/shared_examples_for_jobs.rb +++ b/spec/support/shared_examples_for_jobs.rb @@ -1,11 +1,17 @@ RSpec.shared_examples 'a job retrying transient errors' do |job_class = described_class| - context 'when a transient network error is raised' do - ExconErrorJob = Class.new(job_class) do - def perform - raise Excon::Error::InternalServerError, 'msg' - end + ExconErrorJob = Class.new(job_class) do + def perform + raise Excon::Error::InternalServerError, 'msg' end + end if !defined?(ExconErrorJob) + StandardErrorJob = Class.new(job_class) do + def perform + raise StandardError + end + end if !defined?(StandardErrorJob) + + context 'when a transient network error is raised' do it 'makes 5 attempts before raising the exception up' do assert_performed_jobs 5 do ExconErrorJob.perform_later rescue Excon::Error::InternalServerError @@ -14,12 +20,6 @@ RSpec.shared_examples 'a job retrying transient errors' do |job_class = describe end context 'when another type of error is raised' do - StandardErrorJob = Class.new(job_class) do - def perform - raise StandardError - end - end - it 'makes only 1 attempt before raising the exception up' do assert_performed_jobs 1 do StandardErrorJob.perform_later rescue StandardError