mock_redis 0.32.0 → 0.33.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/mock_redis/database.rb +1 -1
- data/lib/mock_redis/string_methods.rb +8 -2
- data/lib/mock_redis/version.rb +1 -1
- data/mock_redis.gemspec +1 -1
- data/spec/commands/del_spec.rb +1 -1
- data/spec/commands/lpop_spec.rb +1 -0
- data/spec/commands/rpop_spec.rb +1 -0
- data/spec/commands/set_spec.rb +15 -0
- data/spec/spec_helper.rb +4 -1
- data/spec/support/shared_examples/does_not_cleanup_empty_strings.rb +1 -1
- data/spec/support/shared_examples/only_operates_on_lists.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 764d3b747c037b933788f2d4ef01e581ecb509aa8c3e445d12c27d199d2273fe
|
4
|
+
data.tar.gz: 9093a8b7601c57e746dd38d7708c52474df56247ea0910ca4d8d7bcecca9506e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7ef20dba317c18d0ab4de7d5d0a87107512cb2398c7d9c549a603a1980fbced844c7b98c547db32fb905a32ed68cdfa25ba9331b03a91512c8c1d1f6d45551a
|
7
|
+
data.tar.gz: 29570271c68cf37d7fd09c065cdad79e1ac64e9b1aa3bdb28dbf0d2080983cc758ad4632e13ad132d492dc823afef8dd7a7a9cec14dfbefb6a7e49a840c74c8c
|
data/CHANGELOG.md
CHANGED
data/lib/mock_redis/database.rb
CHANGED
@@ -206,8 +206,10 @@ class MockRedis
|
|
206
206
|
|
207
207
|
# Parameer list required to ensure the ArgumentError is returned correctly
|
208
208
|
# rubocop:disable Metrics/ParameterLists
|
209
|
-
def set(key, value, ex: nil, px: nil, nx: nil, xx: nil, keepttl: nil)
|
209
|
+
def set(key, value, ex: nil, px: nil, nx: nil, xx: nil, keepttl: nil, get: nil)
|
210
210
|
key = key.to_s
|
211
|
+
retval = self.get(key) if get
|
212
|
+
|
211
213
|
return_true = false
|
212
214
|
if nx
|
213
215
|
if exists?(key)
|
@@ -240,7 +242,11 @@ class MockRedis
|
|
240
242
|
pexpire(key, px)
|
241
243
|
end
|
242
244
|
|
243
|
-
|
245
|
+
if get
|
246
|
+
retval
|
247
|
+
else
|
248
|
+
return_true ? true : 'OK'
|
249
|
+
end
|
244
250
|
end
|
245
251
|
# rubocop:enable Metrics/ParameterLists
|
246
252
|
|
data/lib/mock_redis/version.rb
CHANGED
data/mock_redis.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
|
26
26
|
s.add_runtime_dependency 'ruby2_keywords'
|
27
27
|
|
28
|
-
s.add_development_dependency 'redis', '~> 4.
|
28
|
+
s.add_development_dependency 'redis', '~> 4.5.0'
|
29
29
|
s.add_development_dependency 'rspec', '~> 3.0'
|
30
30
|
s.add_development_dependency 'rspec-its', '~> 1.0'
|
31
31
|
s.add_development_dependency 'timecop', '~> 0.9.1'
|
data/spec/commands/del_spec.rb
CHANGED
@@ -40,7 +40,7 @@ describe '#del(key [, key, ...])' do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'raises an error if an empty array is given' do
|
43
|
-
expect { @redises.del [] }.
|
43
|
+
expect { @redises.del [] }.not_to raise_error Redis::CommandError
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'removes a stream key' do
|
data/spec/commands/lpop_spec.rb
CHANGED
data/spec/commands/rpop_spec.rb
CHANGED
data/spec/commands/set_spec.rb
CHANGED
@@ -33,6 +33,21 @@ describe '#set(key, value)' do
|
|
33
33
|
@redises.set(key, 1, xx: true).should == true
|
34
34
|
end
|
35
35
|
|
36
|
+
it 'accepts GET on a string' do
|
37
|
+
@redises.set(key, '1').should == 'OK'
|
38
|
+
@redises.set(key, '2', get: true).should == '1'
|
39
|
+
@redises.set(key, '3', get: true).should == '2'
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when set key is not a String' do
|
43
|
+
it 'should error with Redis::CommandError' do
|
44
|
+
@redises.lpush(key, '1').should == 1
|
45
|
+
expect do
|
46
|
+
@redises.set(key, '2', get: true)
|
47
|
+
end.to raise_error(Redis::CommandError)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
36
51
|
it 'sets the ttl to -1' do
|
37
52
|
@redises.set(key, 1)
|
38
53
|
expect(@redises.ttl(key)).to eq(-1)
|
data/spec/spec_helper.rb
CHANGED
@@ -62,7 +62,10 @@ RSpec.configure do |config|
|
|
62
62
|
# databases mentioned in our tests
|
63
63
|
[1, 0].each do |db|
|
64
64
|
@redises.send_without_checking(:select, db)
|
65
|
-
@redises.send_without_checking(:keys, 'mock-redis-test:*')
|
65
|
+
keys = @redises.send_without_checking(:keys, 'mock-redis-test:*')
|
66
|
+
next unless keys.is_a?(Enumerable)
|
67
|
+
|
68
|
+
keys.each do |key|
|
66
69
|
@redises.send_without_checking(:del, key)
|
67
70
|
end
|
68
71
|
end
|
@@ -8,7 +8,7 @@ shared_examples_for 'does not remove empty strings on error' do
|
|
8
8
|
@redises.set(key, '')
|
9
9
|
lambda do
|
10
10
|
@redises.send(method, *args)
|
11
|
-
end.should raise_error(RuntimeError)
|
11
|
+
end.should raise_error(defined?(default_error) ? default_error : RuntimeError)
|
12
12
|
@redises.get(key).should == ''
|
13
13
|
end
|
14
14
|
end
|
@@ -8,7 +8,7 @@ shared_examples_for 'a list-only command' do
|
|
8
8
|
@redises.set(key, 1)
|
9
9
|
lambda do
|
10
10
|
@redises.send(method, *args)
|
11
|
-
end.should raise_error(RuntimeError)
|
11
|
+
end.should raise_error(defined?(default_error) ? default_error : RuntimeError)
|
12
12
|
end
|
13
13
|
|
14
14
|
it_should_behave_like 'does not remove empty strings on error'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mock_redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.33.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane da Silva
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-08-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby2_keywords
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 4.
|
34
|
+
version: 4.5.0
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 4.
|
41
|
+
version: 4.5.0
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|