Skip to content

Commit 48a5b41

Browse files
author
Cosima Radu
committed
Bump version to 2.4.2 and update tests to use mock Redis connection
1 parent 5468fd6 commit 48a5b41

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

lib/cache_store_redis/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module CacheStoreRedis
2-
VERSION = '2.4.1'
2+
VERSION = '2.4.2'.freeze
33
end

spec/cache_store_redis_spec.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,33 @@
66
context 'expires_in' do
77
let(:key) { SecureRandom.uuid }
88
let(:value) { 'SomeValue' }
9+
let(:mock_redis) { instance_double('Redis::MultiConnection') }
10+
11+
before do
12+
allow(Redis::MultiConnection).to receive(:new).and_return(mock_redis)
13+
end
914

1015
it 'will always set a default TTL if one is not provided' do
11-
expect_any_instance_of(Redis::MultiConnection).to receive(:set).with("test:#{key}", "\"#{value}\"")
12-
expect_any_instance_of(Redis::MultiConnection).to receive(:expire).with("test:#{key}", 3_600)
16+
expect_any_instance_of(mock_redis).to receive(:set).with("test:#{key}", "\"#{value}\"")
17+
expect_any_instance_of(mock_redis).to receive(:expire).with("test:#{key}", 3_600)
1318
subject.public_send(method_name, key, value)
1419
end
1520

1621
it 'will always set a default TTL if an invalid one is provided' do
17-
expect_any_instance_of(Redis::MultiConnection).to receive(:set).with("test:#{key}", "\"#{value}\"")
18-
expect_any_instance_of(Redis::MultiConnection).to receive(:expire).with("test:#{key}", 3_600)
22+
expect_any_instance_of(mock_redis).to receive(:set).with("test:#{key}", "\"#{value}\"")
23+
expect_any_instance_of(mock_redis).to receive(:expire).with("test:#{key}", 3_600)
1924
subject.public_send(method_name, key, value, -200)
2025
end
2126

2227
it 'will always set a default TTL if an invalid one is provided' do
23-
expect_any_instance_of(Redis::MultiConnection).to receive(:set).with("test:#{key}", "\"#{value}\"")
24-
expect_any_instance_of(Redis::MultiConnection).to receive(:expire).with("test:#{key}", 3_600)
28+
expect_any_instance_of(mock_redis).to receive(:set).with("test:#{key}", "\"#{value}\"")
29+
expect_any_instance_of(mock_redis).to receive(:expire).with("test:#{key}", 3_600)
2530
subject.public_send(method_name, key, value, 0.456)
2631
end
2732

2833
it 'will always force the TTL to be an integer' do
29-
expect_any_instance_of(Redis::MultiConnection).to receive(:set).with("test:#{key}", "\"#{value}\"")
30-
expect_any_instance_of(Redis::MultiConnection).to receive(:expire).with("test:#{key}", 20)
34+
expect_any_instance_of(mock_redis).to receive(:set).with("test:#{key}", "\"#{value}\"")
35+
expect_any_instance_of(mock_redis).to receive(:expire).with("test:#{key}", 20)
3136
subject.public_send(method_name, key, value, 20.123)
3237
end
3338
end

0 commit comments

Comments
 (0)