From e8cdb1d8a73d662201085c6cab3a5f7e09117942 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 22 Aug 2017 16:54:29 -0400 Subject: [PATCH] correct flaky spec --- spec/components/discourse_redis_spec.rb | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/spec/components/discourse_redis_spec.rb b/spec/components/discourse_redis_spec.rb index 85881ffe02f..dd6c85409fc 100644 --- a/spec/components/discourse_redis_spec.rb +++ b/spec/components/discourse_redis_spec.rb @@ -102,20 +102,6 @@ describe DiscourseRedis do expect(connector.resolve).to eq(config) end - it 'should return the slave config when master is down' do - begin - Redis::Client.any_instance.expects(:call).raises(Redis::CannotConnectError).once - expect { connector.resolve }.to raise_error(Redis::CannotConnectError) - - config = connector.resolve - - expect(config[:host]).to eq(slave_host) - expect(config[:port]).to eq(slave_port) - ensure - fallback_handler.master = true - end - end - class BrokenRedis def initialize(error) @error = error @@ -129,6 +115,20 @@ describe DiscourseRedis do end end + it 'should return the slave config when master is down' do + begin + error = Redis::CannotConnectError + expect { connector.resolve(BrokenRedis.new(error)) }.to raise_error(Redis::CannotConnectError) + + config = connector.resolve + + expect(config[:host]).to eq(slave_host) + expect(config[:port]).to eq(slave_port) + ensure + fallback_handler.master = true + end + end + it "should return the slave config when master's hostname cannot be resolved" do begin error = RuntimeError.new('Name or service not known')