From 35c26367da3fc85f195a693132155a919c11732d Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Wed, 10 Jan 2024 15:32:48 -0800 Subject: [PATCH] chore: Unset Redis config after spec (#8685) The sentinel configuration set in this specification seems to be affecting other specifications. So, let's ensure that the memoised config variable gets unset after execution of the spec. --- spec/lib/redis/config_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/lib/redis/config_spec.rb b/spec/lib/redis/config_spec.rb index 79dc8b03d..296ede54b 100644 --- a/spec/lib/redis/config_spec.rb +++ b/spec/lib/redis/config_spec.rb @@ -42,6 +42,11 @@ describe Redis::Config do end end + after do + # ensuring the redis config is unset and won't affect other tests + described_class.instance_variable_set(:@config, nil) + end + it 'checks for app redis config' do expect(described_class.app.keys).to contain_exactly(:url, :password, :sentinels, :timeout, :reconnect_attempts, :ssl_params) expect(described_class.app[:url]).to eq("redis://#{redis_master_name}") @@ -59,6 +64,11 @@ describe Redis::Config do end end + after do + # ensuring the redis config is unset and won't affect other tests + described_class.instance_variable_set(:@config, nil) + end + it 'checks for app redis config and sentinel passwords will be empty' do expect(described_class.app.keys).to contain_exactly(:url, :password, :sentinels, :timeout, :reconnect_attempts, :ssl_params) expect(described_class.app[:url]).to eq("redis://#{redis_master_name}") @@ -77,6 +87,11 @@ describe Redis::Config do end end + after do + # ensuring the redis config is unset and won't affect other tests + described_class.instance_variable_set(:@config, nil) + end + it 'checks for app redis config and redis password is replaced in sentinel config' do expect(described_class.app.keys).to contain_exactly(:url, :password, :sentinels, :timeout, :reconnect_attempts, :ssl_params) expect(described_class.app[:url]).to eq("redis://#{redis_master_name}")