From c9d22b643f62239d565d68fce138286beadfe25e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guitaut?= Date: Wed, 27 Jul 2022 12:09:47 +0200 Subject: [PATCH] DEV: Fix flaky `FinalDestination` specs --- spec/lib/final_destination_spec.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/lib/final_destination_spec.rb b/spec/lib/final_destination_spec.rb index bd64fb508ef..1e44823709b 100644 --- a/spec/lib/final_destination_spec.rb +++ b/spec/lib/final_destination_spec.rb @@ -427,9 +427,12 @@ describe FinalDestination do describe '#get' do let(:fd) { FinalDestination.new("http://wikipedia.com", opts.merge(verbose: true)) } + before do + described_class.clear_https_cache!("wikipedia.com") + end + context "when there is a redirect" do before do - described_class.clear_https_cache!("wikipedia.com") stub_request(:get, "http://wikipedia.com/"). to_return(status: 302, body: "" , headers: { "location" => "https://wikipedia.com/" }) # webmock does not do chunks @@ -457,12 +460,11 @@ describe FinalDestination do subject(:get) { fd.get {} } before do - described_class.clear_https_cache!("wikipedia.com") fd.stubs(:safe_session).raises(Timeout::Error) end it "logs the exception" do - Rails.logger.expects(:warn).with("default: FinalDestination could not resolve URL (timeout): http://wikipedia.com") + Rails.logger.expects(:warn).with(regexp_matches(/FinalDestination could not resolve URL \(timeout\)/)) get end