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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a63181a124183a90e68a84d2aaa16957e47398e
4
- data.tar.gz: a633c58b9b8eabe402eeb593bfb72fe83e36f069
3
+ metadata.gz: 0e83c6871358c3a1fb0dcec3a3b197e9910781df
4
+ data.tar.gz: 3b08ea384505fc494190e51cfe3f812f8d3f63e8
5
5
  SHA512:
6
- metadata.gz: 41f515662a87bb3a51d2c1f8f5f9f92a0d3d93f9a909a30eb89b03a6a7a454b64d136cb2c3286217e45e9b64252bcd3bc177bae52655f1ad0f8aa773cdaa2b7f
7
- data.tar.gz: f262b7fc4dcf2cfe0a6a44017521a8962ba4769899d65271214a6d909a5aca17f3cbe628b7811d22678e69b014f632d2bc2705032158aebe91f6964b7c768ec4
6
+ metadata.gz: ffe8619a761fdb4898e326b971019e167ea47bf091251b8113f8ee16bfd94d5122c355a7bd87c47503212b076148128a37da1a5efa932f94869ef1b670b0da44
7
+ data.tar.gz: 4d5a6c0cd48dff3cc89f5e71f7899e6fae2bac72f14ac5e4eccd2705ebad0ed99f0a23786314df43f468907cab2188ccbc8c0e81ccfe09facad072f0362dbecd
data/.travis.yml CHANGED
@@ -4,4 +4,9 @@ services:
4
4
  rvm:
5
5
  - 1.9.3
6
6
  - 2.0.0
7
+ - 2.1.1
7
8
  - jruby-19mode
9
+
10
+ matrix:
11
+ allow_failures:
12
+ - rvm: 2.1.0
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
@@ -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
@@ -33,6 +33,7 @@ class MockRedis
33
33
  end
34
34
 
35
35
  def brpoplpush(source, destination, options = {})
36
+ options = { :timeout => options } if options.kind_of?(Integer)
36
37
  timeout = options.is_a?(Hash) && options[:timeout] || 0
37
38
  assert_valid_timeout(timeout)
38
39
 
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  class MockRedis
3
- VERSION = '0.13.0'
3
+ VERSION = '0.13.1'
4
4
  end
@@ -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)
@@ -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)
@@ -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.0
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-02 00:00:00.000000000 Z
12
+ date: 2014-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake