mock_redis 0.13.0 → 0.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/CHANGELOG.md +6 -0
- data/lib/mock_redis/database.rb +4 -0
- data/lib/mock_redis/list_methods.rb +1 -0
- data/lib/mock_redis/version.rb +1 -1
- data/spec/commands/blpop_spec.rb +4 -0
- data/spec/commands/brpop_spec.rb +4 -0
- data/spec/commands/brpoplpush_spec.rb +5 -0
- data/spec/commands/keys_spec.rb +34 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e83c6871358c3a1fb0dcec3a3b197e9910781df
|
4
|
+
data.tar.gz: 3b08ea384505fc494190e51cfe3f812f8d3f63e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffe8619a761fdb4898e326b971019e167ea47bf091251b8113f8ee16bfd94d5122c355a7bd87c47503212b076148128a37da1a5efa932f94869ef1b670b0da44
|
7
|
+
data.tar.gz: 4d5a6c0cd48dff3cc89f5e71f7899e6fae2bac72f14ac5e4eccd2705ebad0ed99f0a23786314df43f468907cab2188ccbc8c0e81ccfe09facad072f0362dbecd
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# MockRedis Changelog
|
2
2
|
|
3
|
+
### 0.13.1
|
4
|
+
|
5
|
+
* Fix bug where certain characters in keys were treated as regex characters
|
6
|
+
rather than literals
|
7
|
+
* Add back support for legacy integer timeouts on blocking list commands
|
8
|
+
|
3
9
|
### 0.13.0
|
4
10
|
|
5
11
|
* Fix bug where SETBIT command would not correctly unset a bit
|
data/lib/mock_redis/database.rb
CHANGED
@@ -231,6 +231,9 @@ class MockRedis
|
|
231
231
|
if options.is_a?(Hash) && options[:timeout]
|
232
232
|
timeout = assert_valid_timeout(options[:timeout])
|
233
233
|
[arglist[0..-2], timeout]
|
234
|
+
elsif options.kind_of?(Integer)
|
235
|
+
timeout = assert_valid_timeout(options)
|
236
|
+
[arglist[0..-2], timeout]
|
234
237
|
else
|
235
238
|
[arglist, 0]
|
236
239
|
end
|
@@ -255,6 +258,7 @@ class MockRedis
|
|
255
258
|
def redis_pattern_to_ruby_regex(pattern)
|
256
259
|
Regexp.new(
|
257
260
|
"^#{pattern}$".
|
261
|
+
gsub(/([+|()])/, '\\\\\1').
|
258
262
|
gsub(/([^\\])\?/, "\\1.").
|
259
263
|
gsub(/([^\\])\*/, "\\1.*"))
|
260
264
|
end
|
data/lib/mock_redis/version.rb
CHANGED
data/spec/commands/blpop_spec.rb
CHANGED
@@ -46,6 +46,10 @@ describe '#blpop(key [, key, ...,], timeout)' do
|
|
46
46
|
@redises.mock.blpop('mock-redis-test:not-here', :timeout => 1).should be_nil
|
47
47
|
end
|
48
48
|
|
49
|
+
it "ignores positive legacy timeouts and returns nil" do
|
50
|
+
@redises.mock.blpop('mock-redis-test:not-here', 1).should be_nil
|
51
|
+
end
|
52
|
+
|
49
53
|
it "raises WouldBlock on zero timeout (no blocking in the mock)" do
|
50
54
|
lambda do
|
51
55
|
@redises.mock.blpop('mock-redis-test:not-here', :timeout => 0)
|
data/spec/commands/brpop_spec.rb
CHANGED
@@ -45,6 +45,10 @@ describe '#brpop(key [, key, ...,], timeout)' do
|
|
45
45
|
@redises.mock.brpop('mock-redis-test:not-here', :timeout => 1).should be_nil
|
46
46
|
end
|
47
47
|
|
48
|
+
it "ignores positive legacy timeouts and returns nil" do
|
49
|
+
@redises.mock.brpop('mock-redis-test:not-here', 1).should be_nil
|
50
|
+
end
|
51
|
+
|
48
52
|
it "raises WouldBlock on zero timeout (no blocking in the mock)" do
|
49
53
|
lambda do
|
50
54
|
@redises.mock.brpop('mock-redis-test:not-here', :timeout => 0)
|
@@ -38,6 +38,11 @@ describe '#brpoplpush(source, destination, timeout)' do
|
|
38
38
|
should be_nil
|
39
39
|
end
|
40
40
|
|
41
|
+
it "ignores positive legacy timeouts and returns nil" do
|
42
|
+
@redises.mock.brpoplpush('mock-redis-test:not-here', @list1, 1).
|
43
|
+
should be_nil
|
44
|
+
end
|
45
|
+
|
41
46
|
it "raises WouldBlock on zero timeout (no blocking in the mock)" do
|
42
47
|
lambda do
|
43
48
|
@redises.mock.brpoplpush('mock-redis-test:not-here', @list1, :timeout => 0)
|
data/spec/commands/keys_spec.rb
CHANGED
@@ -20,6 +20,14 @@ describe '#keys()' do
|
|
20
20
|
@redises.set("mock-redis-test:key20", 20)
|
21
21
|
@redises.set("mock-redis-test:key30", 30)
|
22
22
|
|
23
|
+
@redises.set("mock-redis-test:regexp-key(1|22)", 40)
|
24
|
+
@redises.set("mock-redis-test:regexp-key3+", 40)
|
25
|
+
@redises.set("mock-redis-test:regexp-key33", 40)
|
26
|
+
@redises.set("mock-redis-test:regexp-key4a", 40)
|
27
|
+
@redises.set("mock-redis-test:regexp-key4-", 40)
|
28
|
+
@redises.set("mock-redis-test:regexp-key4b", 40)
|
29
|
+
@redises.set("mock-redis-test:regexp-key4c", 40)
|
30
|
+
|
23
31
|
@redises.set("mock-redis-test:special-key?", 'true')
|
24
32
|
@redises.set("mock-redis-test:special-key*", 'true')
|
25
33
|
end
|
@@ -77,6 +85,32 @@ describe '#keys()' do
|
|
77
85
|
end
|
78
86
|
end
|
79
87
|
|
88
|
+
describe "the | character" do
|
89
|
+
it "is treated as literal (not 'or')" do
|
90
|
+
@redises.keys('mock-redis-test:regexp-key(1|22)').sort.should == [
|
91
|
+
'mock-redis-test:regexp-key(1|22)'
|
92
|
+
]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "the + character" do
|
97
|
+
it "is treated as literal (not 'one or more' quantifier)" do
|
98
|
+
@redises.keys('mock-redis-test:regexp-key3+').sort.should == [
|
99
|
+
'mock-redis-test:regexp-key3+'
|
100
|
+
]
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "character classes ([a-c])" do
|
105
|
+
it "specifies a range which matches any lowercase letter from \"a\" to \"c\"" do
|
106
|
+
@redises.keys('mock-redis-test:regexp-key4[a-c]').sort.should == [
|
107
|
+
'mock-redis-test:regexp-key4a',
|
108
|
+
'mock-redis-test:regexp-key4b',
|
109
|
+
'mock-redis-test:regexp-key4c',
|
110
|
+
]
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
80
114
|
describe "combining metacharacters" do
|
81
115
|
it "works with different metacharacters simultaneously" do
|
82
116
|
@redises.keys('mock-redis-test:k*[12]?').sort.should == [
|
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.13.
|
4
|
+
version: 0.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Causes Engineering
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-05-
|
12
|
+
date: 2014-05-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|