redis-store 1.6.0 → 1.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,55 +6,55 @@ describe "Redis::Store::Factory" do
6
6
  describe "when not given any arguments" do
7
7
  it "instantiates Redis::Store" do
8
8
  store = Redis::Store::Factory.create
9
- store.must_be_kind_of(Redis::Store)
10
- store.to_s.must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0")
9
+ _(store).must_be_kind_of(Redis::Store)
10
+ _(store.to_s).must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0")
11
11
  end
12
12
  end
13
13
 
14
14
  describe "when given a Hash" do
15
15
  it "uses specified host" do
16
16
  store = Redis::Store::Factory.create :host => "localhost"
17
- store.to_s.must_equal("Redis Client connected to localhost:6379 against DB 0")
17
+ _(store.to_s).must_equal("Redis Client connected to localhost:6379 against DB 0")
18
18
  end
19
19
 
20
20
  it "uses specified port" do
21
21
  store = Redis::Store::Factory.create :host => "localhost", :port => 6380
22
- store.to_s.must_equal("Redis Client connected to localhost:6380 against DB 0")
22
+ _(store.to_s).must_equal("Redis Client connected to localhost:6380 against DB 0")
23
23
  end
24
24
 
25
25
  it "uses specified scheme" do
26
26
  store = Redis::Store::Factory.create :scheme => "rediss"
27
- store.instance_variable_get(:@client).scheme.must_equal('rediss')
27
+ _(store.instance_variable_get(:@client).scheme).must_equal('rediss')
28
28
  end
29
29
 
30
30
  it "uses specified path" do
31
31
  store = Redis::Store::Factory.create :path => "/var/run/redis.sock"
32
- store.to_s.must_equal("Redis Client connected to /var/run/redis.sock against DB 0")
32
+ _(store.to_s).must_equal("Redis Client connected to /var/run/redis.sock against DB 0")
33
33
  end
34
34
 
35
35
  it "uses specified db" do
36
36
  store = Redis::Store::Factory.create :host => "localhost", :port => 6380, :db => 13
37
- store.to_s.must_equal("Redis Client connected to localhost:6380 against DB 13")
37
+ _(store.to_s).must_equal("Redis Client connected to localhost:6380 against DB 13")
38
38
  end
39
39
 
40
40
  it "uses specified namespace" do
41
41
  store = Redis::Store::Factory.create :namespace => "theplaylist"
42
- store.to_s.must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
42
+ _(store.to_s).must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
43
43
  end
44
44
 
45
45
  it "uses specified key_prefix as namespace" do
46
46
  store = Redis::Store::Factory.create :key_prefix => "theplaylist"
47
- store.to_s.must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
47
+ _(store.to_s).must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
48
48
  end
49
49
 
50
50
  it "uses specified password" do
51
51
  store = Redis::Store::Factory.create :password => "secret"
52
- store.instance_variable_get(:@client).password.must_equal("secret")
52
+ _(store.instance_variable_get(:@client).password).must_equal("secret")
53
53
  end
54
54
 
55
55
  it 'uses empty password' do
56
56
  store = Redis::Store::Factory.create :password => ''
57
- store.instance_variable_get(:@client).password.must_equal('')
57
+ _(store.instance_variable_get(:@client).password).must_equal('')
58
58
  end
59
59
 
60
60
  it 'uses nil password' do
@@ -64,30 +64,30 @@ describe "Redis::Store::Factory" do
64
64
 
65
65
  it "disables serialization" do
66
66
  store = Redis::Store::Factory.create :serializer => nil
67
- store.instance_variable_get(:@serializer).must_be_nil
68
- store.instance_variable_get(:@options)[:raw].must_equal(true)
67
+ _(store.instance_variable_get(:@serializer)).must_be_nil
68
+ _(store.instance_variable_get(:@options)[:raw]).must_equal(true)
69
69
  end
70
70
 
71
71
  it "configures pluggable serialization backend" do
72
72
  store = Redis::Store::Factory.create :serializer => JSON
73
- store.instance_variable_get(:@serializer).must_equal(JSON)
74
- store.instance_variable_get(:@options)[:raw].must_equal(false)
73
+ _(store.instance_variable_get(:@serializer)).must_equal(JSON)
74
+ _(store.instance_variable_get(:@options)[:raw]).must_equal(false)
75
75
  end
76
76
 
77
77
  describe "defaults" do
78
78
  it "defaults to localhost if no host specified" do
79
79
  store = Redis::Store::Factory.create
80
- store.instance_variable_get(:@client).host.must_equal('127.0.0.1')
80
+ _(store.instance_variable_get(:@client).host).must_equal('127.0.0.1')
81
81
  end
82
82
 
83
83
  it "defaults to 6379 if no port specified" do
84
84
  store = Redis::Store::Factory.create
85
- store.instance_variable_get(:@client).port.must_equal(6379)
85
+ _(store.instance_variable_get(:@client).port).must_equal(6379)
86
86
  end
87
87
 
88
88
  it "defaults to redis:// if no scheme specified" do
89
89
  store = Redis::Store::Factory.create
90
- store.instance_variable_get(:@client).scheme.must_equal('redis')
90
+ _(store.instance_variable_get(:@client).scheme).must_equal('redis')
91
91
  end
92
92
  end
93
93
 
@@ -102,14 +102,14 @@ describe "Redis::Store::Factory" do
102
102
 
103
103
  it "disables marshalling and provides deprecation warning" do
104
104
  store = Redis::Store::Factory.create :marshalling => false
105
- store.instance_variable_get(:@serializer).must_be_nil
106
- store.instance_variable_get(:@options)[:raw].must_equal(true)
105
+ _(store.instance_variable_get(:@serializer)).must_be_nil
106
+ _(store.instance_variable_get(:@options)[:raw]).must_equal(true)
107
107
  end
108
108
 
109
109
  it "enables marshalling but provides warning to use :serializer instead" do
110
110
  store = Redis::Store::Factory.create :marshalling => true
111
- store.instance_variable_get(:@serializer).must_equal(Marshal)
112
- store.instance_variable_get(:@options)[:raw].must_equal(false)
111
+ _(store.instance_variable_get(:@serializer)).must_equal(Marshal)
112
+ _(store.instance_variable_get(:@options)[:raw]).must_equal(false)
113
113
  end
114
114
 
115
115
  after do
@@ -123,8 +123,8 @@ describe "Redis::Store::Factory" do
123
123
  { :host => "localhost", :port => 6379 },
124
124
  { :host => "localhost", :port => 6380 }
125
125
  )
126
- store.must_be_kind_of(Redis::DistributedStore)
127
- store.nodes.map { |node| node.to_s }.must_equal([
126
+ _(store).must_be_kind_of(Redis::DistributedStore)
127
+ _(store.nodes.map { |node| node.to_s }).must_equal([
128
128
  "Redis Client connected to localhost:6379 against DB 0",
129
129
  "Redis Client connected to localhost:6380 against DB 0",
130
130
  ])
@@ -134,62 +134,62 @@ describe "Redis::Store::Factory" do
134
134
  describe "when given a String" do
135
135
  it "uses specified host" do
136
136
  store = Redis::Store::Factory.create "redis://127.0.0.1"
137
- store.to_s.must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0")
137
+ _(store.to_s).must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0")
138
138
  end
139
139
 
140
140
  it "uses specified port" do
141
141
  store = Redis::Store::Factory.create "redis://127.0.0.1:6380"
142
- store.to_s.must_equal("Redis Client connected to 127.0.0.1:6380 against DB 0")
142
+ _(store.to_s).must_equal("Redis Client connected to 127.0.0.1:6380 against DB 0")
143
143
  end
144
144
 
145
145
  it "uses specified scheme" do
146
146
  store = Redis::Store::Factory.create "rediss://127.0.0.1:6380"
147
- store.instance_variable_get(:@client).scheme.must_equal('rediss')
147
+ _(store.instance_variable_get(:@client).scheme).must_equal('rediss')
148
148
  end
149
149
 
150
150
  it "correctly defaults to redis:// when relative scheme specified" do
151
151
  store = Redis::Store::Factory.create "//127.0.0.1:6379"
152
- store.instance_variable_get(:@client).scheme.must_equal('redis')
152
+ _(store.instance_variable_get(:@client).scheme).must_equal('redis')
153
153
  end
154
154
 
155
155
  it "uses specified path" do
156
156
  store = Redis::Store::Factory.create "unix:///var/run/redis.sock"
157
- store.to_s.must_equal("Redis Client connected to /var/run/redis.sock against DB 0")
157
+ _(store.to_s).must_equal("Redis Client connected to /var/run/redis.sock against DB 0")
158
158
  end
159
159
 
160
160
  it "uses specified db" do
161
161
  store = Redis::Store::Factory.create "redis://127.0.0.1:6380/13"
162
- store.to_s.must_equal("Redis Client connected to 127.0.0.1:6380 against DB 13")
162
+ _(store.to_s).must_equal("Redis Client connected to 127.0.0.1:6380 against DB 13")
163
163
  end
164
164
 
165
165
  it "uses specified namespace" do
166
166
  store = Redis::Store::Factory.create "redis://127.0.0.1:6379/0/theplaylist"
167
- store.to_s.must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
167
+ _(store.to_s).must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
168
168
  end
169
169
 
170
170
  it "uses specified via query namespace" do
171
171
  store = Redis::Store::Factory.create "redis://127.0.0.1:6379/0?namespace=theplaylist"
172
- store.to_s.must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
172
+ _(store.to_s).must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
173
173
  end
174
174
 
175
175
  it "uses specified namespace with path" do
176
176
  store = Redis::Store::Factory.create "unix:///var/run/redis.sock?db=2&namespace=theplaylist"
177
- store.to_s.must_equal("Redis Client connected to /var/run/redis.sock against DB 2 with namespace theplaylist")
177
+ _(store.to_s).must_equal("Redis Client connected to /var/run/redis.sock against DB 2 with namespace theplaylist")
178
178
  end
179
179
 
180
180
  it "uses specified password" do
181
181
  store = Redis::Store::Factory.create "redis://:secret@127.0.0.1:6379/0/theplaylist"
182
- store.instance_variable_get(:@client).password.must_equal("secret")
182
+ _(store.instance_variable_get(:@client).password).must_equal("secret")
183
183
  end
184
184
 
185
185
  it 'uses specified password with special characters' do
186
186
  store = Redis::Store::Factory.create 'redis://:pwd%40123@127.0.0.1:6379/0/theplaylist'
187
- store.instance_variable_get(:@client).password.must_equal('pwd@123')
187
+ _(store.instance_variable_get(:@client).password).must_equal('pwd@123')
188
188
  end
189
189
 
190
190
  it 'uses empty password' do
191
191
  store = Redis::Store::Factory.create 'redis://:@127.0.0.1:6379/0/theplaylist'
192
- store.instance_variable_get(:@client).password.must_equal('')
192
+ _(store.instance_variable_get(:@client).password).must_equal('')
193
193
  end
194
194
 
195
195
  it 'uses nil password' do
@@ -199,14 +199,14 @@ describe "Redis::Store::Factory" do
199
199
 
200
200
  it "correctly uses specified ipv6 host" do
201
201
  store = Redis::Store::Factory.create "redis://[::1]:6380"
202
- store.to_s.must_equal("Redis Client connected to [::1]:6380 against DB 0")
203
- store.instance_variable_get('@options')[:host].must_equal("::1")
202
+ _(store.to_s).must_equal("Redis Client connected to [::1]:6380 against DB 0")
203
+ _(store.instance_variable_get('@options')[:host]).must_equal("::1")
204
204
  end
205
205
 
206
206
  it "instantiates Redis::DistributedStore" do
207
207
  store = Redis::Store::Factory.create "redis://127.0.0.1:6379", "redis://127.0.0.1:6380"
208
- store.must_be_kind_of(Redis::DistributedStore)
209
- store.nodes.map { |node| node.to_s }.must_equal([
208
+ _(store).must_be_kind_of(Redis::DistributedStore)
209
+ _(store.nodes.map { |node| node.to_s }).must_equal([
210
210
  "Redis Client connected to 127.0.0.1:6379 against DB 0",
211
211
  "Redis Client connected to 127.0.0.1:6380 against DB 0",
212
212
  ])
@@ -227,7 +227,7 @@ describe "Redis::Store::Factory" do
227
227
  { :host => '127.0.0.1', :port => '6380' },
228
228
  { :namespace => 'theplaylist' }
229
229
  )
230
- store.nodes.map { |node| node.to_s }.must_equal([
230
+ _(store.nodes.map { |node| node.to_s }).must_equal([
231
231
  "Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist",
232
232
  "Redis Client connected to 127.0.0.1:6380 against DB 0 with namespace theplaylist"
233
233
  ])
@@ -237,12 +237,12 @@ describe "Redis::Store::Factory" do
237
237
  describe 'when given host String and options Hash' do
238
238
  it 'instantiates Redis::Store and merges options' do
239
239
  store = Redis::Store::Factory.create "redis://127.0.0.1", :namespace => 'theplaylist'
240
- store.to_s.must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
240
+ _(store.to_s).must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
241
241
  end
242
242
 
243
243
  it 'instantiates Redis::DistributedStore and merges options' do
244
244
  store = Redis::Store::Factory.create "redis://127.0.0.1:6379", "redis://127.0.0.1:6380", :namespace => 'theplaylist'
245
- store.nodes.map { |node| node.to_s }.must_equal([
245
+ _(store.nodes.map { |node| node.to_s }).must_equal([
246
246
  "Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist",
247
247
  "Redis Client connected to 127.0.0.1:6380 against DB 0 with namespace theplaylist",
248
248
  ])
@@ -250,7 +250,7 @@ describe "Redis::Store::Factory" do
250
250
 
251
251
  it 'instantiates Redis::Store and sets namespace from String' do
252
252
  store = Redis::Store::Factory.create "redis://127.0.0.1:6379/0/theplaylist", :expire_after => 5
253
- store.to_s.must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
253
+ _(store.to_s).must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
254
254
  end
255
255
  end
256
256
  end
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  describe "Redis::Store::Namespace" do
4
4
  def setup
5
5
  @namespace = "theplaylist"
6
- @store = Redis::Store.new :namespace => @namespace, :serializer => nil
6
+ @store = Redis::Store.new :namespace => @namespace, :serializer => nil
7
7
  @client = @store.instance_variable_get(:@client)
8
8
  @rabbit = "bunny"
9
9
  @default_store = Redis::Store.new
@@ -30,7 +30,7 @@ describe "Redis::Store::Namespace" do
30
30
  end
31
31
 
32
32
  it "doesn't namespace a key which is already namespaced" do
33
- @store.send(:interpolate, "#{@namespace}:rabbit").must_equal("#{@namespace}:rabbit")
33
+ _(@store.send(:interpolate, "#{@namespace}:rabbit")).must_equal("#{@namespace}:rabbit")
34
34
  end
35
35
 
36
36
  it "should only delete namespaced keys" do
@@ -38,26 +38,26 @@ describe "Redis::Store::Namespace" do
38
38
  @store.set 'def', 'fed'
39
39
 
40
40
  @store.flushdb
41
- @store.get('def').must_be_nil
42
- @default_store.get('abc').must_equal('cba')
41
+ _(@store.get('def')).must_be_nil
42
+ _(@default_store.get('abc')).must_equal('cba')
43
43
  end
44
44
 
45
45
  it 'should allow to change namespace on the fly' do
46
46
  @default_store.set 'abc', 'cba'
47
47
  @other_store.set 'foo', 'bar'
48
48
 
49
- @default_store.keys.sort.must_equal ['abc', 'other:foo']
49
+ _(@default_store.keys.sort).must_equal ['abc', 'other:foo']
50
50
 
51
51
  @default_store.with_namespace(@other_namespace) do
52
- @default_store.keys.must_equal ['foo']
53
- @default_store.get('foo').must_equal('bar')
52
+ _(@default_store.keys).must_equal ['foo']
53
+ _(@default_store.get('foo')).must_equal('bar')
54
54
  end
55
55
  end
56
56
 
57
57
  it "should not try to delete missing namespaced keys" do
58
58
  empty_store = Redis::Store.new :namespace => 'empty'
59
59
  empty_store.flushdb
60
- empty_store.keys.must_be_empty
60
+ _(empty_store.keys).must_be_empty
61
61
  end
62
62
 
63
63
  it "should work with dynamic namespace" do
@@ -74,7 +74,7 @@ describe "Redis::Store::Namespace" do
74
74
  r2 = dyn_store.get 'key'
75
75
  $ns = "ns1"
76
76
  r1 = dyn_store.get 'key'
77
- r1.must_equal('x') && r2.must_equal('y') && r3.must_be_nil
77
+ _(r1).must_equal('x') && _(r2).must_equal('y') && _(r3).must_be_nil
78
78
  end
79
79
 
80
80
  it "namespaces setex and ttl" do
@@ -82,11 +82,11 @@ describe "Redis::Store::Namespace" do
82
82
  @other_store.flushdb
83
83
 
84
84
  @store.setex('foo', 30, 'bar')
85
- @store.ttl('foo').must_be_close_to(30)
86
- @store.get('foo').must_equal('bar')
85
+ _(@store.ttl('foo')).must_be_close_to(30)
86
+ _(@store.get('foo')).must_equal('bar')
87
87
 
88
- @other_store.ttl('foo').must_equal(-2)
89
- @other_store.get('foo').must_be_nil
88
+ _(@other_store.ttl('foo')).must_equal(-2)
89
+ _(@other_store.get('foo')).must_be_nil
90
90
  end
91
91
 
92
92
  describe 'method calls' do
@@ -120,7 +120,18 @@ describe "Redis::Store::Namespace" do
120
120
 
121
121
  it "should namespace keys" do
122
122
  store.set "rabbit", @rabbit
123
- store.keys("rabb*").must_equal [ "rabbit" ]
123
+ _(store.keys("rabb*")).must_equal [ "rabbit" ]
124
+ end
125
+
126
+ it "should namespace scan when a pattern is given" do
127
+ store.set "rabbit", @rabbit
128
+ cursor = "0"
129
+ keys = []
130
+ begin
131
+ cursor, matched_keys = store.scan(cursor, match: "rabb*")
132
+ keys = keys.concat(matched_keys) unless matched_keys.empty?
133
+ end until cursor == "0"
134
+ _(keys).must_equal [ "rabbit" ]
124
135
  end
125
136
 
126
137
  it "should namespace exists" do
@@ -141,16 +152,16 @@ describe "Redis::Store::Namespace" do
141
152
  it "should namespace mget" do
142
153
  client.expects(:call).with([:mget, "#{@namespace}:rabbit", "#{@namespace}:white_rabbit"]).returns(%w[ foo bar ])
143
154
  store.mget "rabbit", "white_rabbit" do |result|
144
- result.must_equal(%w[ foo bar ])
155
+ _(result).must_equal(%w[ foo bar ])
145
156
  end
146
157
  end
147
158
 
148
159
  it "should namespace mapped_mget" do
149
160
  client.expects(:process).with([[:mget, "#{@namespace}:rabbit", "#{@namespace}:white_rabbit"]]).returns(%w[ foo bar ])
150
161
  result = store.mapped_mget "rabbit", "white_rabbit"
151
- result.keys.must_equal %w[ rabbit white_rabbit ]
152
- result["rabbit"].must_equal "foo"
153
- result["white_rabbit"].must_equal "bar"
162
+ _(result.keys).must_equal %w[ rabbit white_rabbit ]
163
+ _(result["rabbit"]).must_equal "foo"
164
+ _(result["white_rabbit"]).must_equal "bar"
154
165
  end
155
166
 
156
167
  it "should namespace expire" do
@@ -182,5 +193,112 @@ describe "Redis::Store::Namespace" do
182
193
  store.flushdb
183
194
  end
184
195
  end
196
+
197
+ it "should namespace hdel" do
198
+ client.expects(:call).with([:hdel, "#{@namespace}:rabbit", "key1", "key2"]).once
199
+ store.hdel("rabbit", "key1", "key2")
200
+ end
201
+
202
+ it "should namespace hget" do
203
+ client.expects(:call).with([:hget, "#{@namespace}:rabbit", "key"]).once
204
+ store.hget("rabbit", "key")
205
+ end
206
+
207
+ it "should namespace hgetall" do
208
+ client.expects(:call).with([:hgetall, "#{@namespace}:rabbit"]).once
209
+ store.hgetall("rabbit")
210
+ end
211
+
212
+ it "should namespace hexists" do
213
+ client.expects(:call).with([:hexists, "#{@namespace}:rabbit", "key"]).once
214
+ results = store.hexists("rabbit", "key")
215
+ end
216
+
217
+ it "should namespace hincrby" do
218
+ client.expects(:call).with([:hincrby, "#{@namespace}:rabbit", "key", 1]).once
219
+ store.hincrby("rabbit", "key", 1)
220
+ end
221
+
222
+ it "should namespace hincrbyfloat" do
223
+ client.expects(:call).with([:hincrby, "#{@namespace}:rabbit", "key", 1.5]).once
224
+ store.hincrby("rabbit", "key", 1.5)
225
+ end
226
+
227
+ it "should namespace hkeys" do
228
+ client.expects(:call).with([:hkeys, "#{@namespace}:rabbit"])
229
+ store.hkeys("rabbit")
230
+ end
231
+
232
+ it "should namespace hlen" do
233
+ client.expects(:call).with([:hlen, "#{@namespace}:rabbit"])
234
+ store.hlen("rabbit")
235
+ end
236
+
237
+ it "should namespace hmget" do
238
+ client.expects(:call).with([:hmget, "#{@namespace}:rabbit", "key1", "key2"])
239
+ store.hmget("rabbit", "key1", "key2")
240
+ end
241
+
242
+ it "should namespace hmset" do
243
+ client.expects(:call).with([:hmset, "#{@namespace}:rabbit", "key", @rabbit])
244
+ store.hmset("rabbit", "key", @rabbit)
245
+ end
246
+
247
+ it "should namespace hset" do
248
+ client.expects(:call).with([:hset, "#{@namespace}:rabbit", "key", @rabbit])
249
+ store.hset("rabbit", "key", @rabbit)
250
+ end
251
+
252
+ it "should namespace hsetnx" do
253
+ client.expects(:call).with([:hsetnx, "#{@namespace}:rabbit", "key", @rabbit])
254
+ store.hsetnx("rabbit", "key", @rabbit)
255
+ end
256
+
257
+ it "should namespace hvals" do
258
+ client.expects(:call).with([:hvals, "#{@namespace}:rabbit"])
259
+ store.hvals("rabbit")
260
+ end
261
+
262
+ it "should namespace hscan" do
263
+ client.expects(:call).with([:hscan, "#{@namespace}:rabbit", 0])
264
+ store.hscan("rabbit", 0)
265
+ end
266
+
267
+ it "should namespace hscan_each with block" do
268
+ client.call([:hset, "#{@namespace}:rabbit", "key1", @rabbit])
269
+ client.expects(:call).with([:hscan, "#{@namespace}:rabbit", 0]).returns(["0", ["key1"]])
270
+ results = []
271
+ store.hscan_each("rabbit") do |key|
272
+ results << key
273
+ end
274
+ _(results).must_equal(["key1"])
275
+ end
276
+
277
+ it "should namespace hscan_each without block" do
278
+ client.call([:hset, "#{@namespace}:rabbit", "key1", @rabbit])
279
+ client.expects(:call).with([:hscan, "#{@namespace}:rabbit", 0]).returns(["0", ["key1"]])
280
+ results = store.hscan_each("rabbit").to_a
281
+ _(results).must_equal(["key1"])
282
+ end
283
+
284
+ it "should namespace zincrby" do
285
+ client.expects(:call).with([:zincrby, "#{@namespace}:rabbit", 1.0, "member"])
286
+ store.zincrby("rabbit", 1.0, "member")
287
+ end
288
+
289
+ it "should namespace zscore" do
290
+ client.expects(:call).with([:zscore, "#{@namespace}:rabbit", "member"])
291
+ store.zscore("rabbit", "member")
292
+ end
293
+
294
+ it "should namespace zadd" do
295
+ client.expects(:call).with([:zadd, "#{@namespace}:rabbit", 1.0, "member"])
296
+ store.zadd("rabbit", 1.0, "member")
297
+ end
298
+
299
+ it "should namespace zrem" do
300
+ client.expects(:call).with([:zrem, "#{@namespace}:rabbit", "member"])
301
+ store.zrem("rabbit", "member")
302
+ end
185
303
  end
186
304
  end
@@ -11,18 +11,18 @@ describe "Redis::RedisVersion" do
11
11
 
12
12
  describe '#redis_version' do
13
13
  it 'returns redis version' do
14
- @store.redis_version.to_s.must_match(/^\d{1}\.\d{1,}\.\d{1,}$/)
14
+ _(@store.redis_version.to_s).must_match(/^\d{1}\.\d{1,}\.\d{1,}$/)
15
15
  end
16
16
  end
17
17
 
18
18
  describe '#supports_redis_version?' do
19
19
  it 'returns true if redis version is greater or equal to required version' do
20
20
  @store.stubs(:redis_version).returns('2.8.19')
21
- @store.supports_redis_version?('2.6.0').must_equal(true)
22
- @store.supports_redis_version?('2.8.19').must_equal(true)
23
- @store.supports_redis_version?('2.8.20').must_equal(false)
24
- @store.supports_redis_version?('2.9.0').must_equal(false)
25
- @store.supports_redis_version?('3.0.0').must_equal(false)
21
+ _(@store.supports_redis_version?('2.6.0')).must_equal(true)
22
+ _(@store.supports_redis_version?('2.8.19')).must_equal(true)
23
+ _(@store.supports_redis_version?('2.8.20')).must_equal(false)
24
+ _(@store.supports_redis_version?('2.9.0')).must_equal(false)
25
+ _(@store.supports_redis_version?('3.0.0')).must_equal(false)
26
26
  end
27
27
  end
28
28
  end