From 88339b365791c42996395a334a4362e219d372a5 Mon Sep 17 00:00:00 2001 From: KMY Date: Wed, 9 Aug 2023 10:25:44 +0900 Subject: [PATCH] Fix poll expiration notify worker spec sometimes return error --- Gemfile | 2 ++ Gemfile.lock | 3 +++ spec/spec_helper.rb | 6 ++++++ spec/workers/poll_expiration_notify_worker_spec.rb | 2 +- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 27adec7a09..11233bcf08 100644 --- a/Gemfile +++ b/Gemfile @@ -142,6 +142,8 @@ group :test do # Stub web requests for specs gem 'webmock', '~> 3.18' + + gem 'rspec-retry', '>= 0.6.2' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 46a10e5acc..84d09ffe9d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -632,6 +632,8 @@ GEM rspec-expectations (~> 3.12) rspec-mocks (~> 3.12) rspec-support (~> 3.12) + rspec-retry (0.6.2) + rspec-core (> 3.3) rspec-sidekiq (3.1.0) rspec-core (~> 3.0, >= 3.0.0) sidekiq (>= 2.4.0) @@ -909,6 +911,7 @@ DEPENDENCIES redis-namespace (~> 1.10) rqrcode (~> 2.2) rspec-rails (~> 6.0) + rspec-retry (>= 0.6.2) rspec-sidekiq (~> 3.1) rspec_chunked (~> 0.6) rubocop diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index dcbcad48e6..8c5072d883 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'rspec/retry' + if ENV['DISABLE_SIMPLECOV'] != 'true' require 'simplecov' SimpleCov.start 'rails' do @@ -36,6 +38,10 @@ RSpec.configure do |config| config.after :suite do FileUtils.rm_rf(Dir[Rails.root.join('spec', 'test_files')]) end + + # for RSpec::Retry + config.verbose_retry = true + config.display_try_failure_messages = true end def body_as_json diff --git a/spec/workers/poll_expiration_notify_worker_spec.rb b/spec/workers/poll_expiration_notify_worker_spec.rb index 78cbc1ee40..26f2d2b5c1 100644 --- a/spec/workers/poll_expiration_notify_worker_spec.rb +++ b/spec/workers/poll_expiration_notify_worker_spec.rb @@ -22,7 +22,7 @@ describe PollExpirationNotifyWorker do end context 'when poll is not expired' do - it 'requeues job' do + it 'requeues job', retry: 10 do worker.perform(poll.id) expect(described_class.sidekiq_options_hash['lock']).to be :until_executing expect(described_class).to have_enqueued_sidekiq_job(poll.id).at(poll.expires_at + 5.minutes)