mock_redis 0.6.4 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +5 -0
- data/lib/mock_redis/database.rb +4 -4
- data/lib/mock_redis/indifferent_hash.rb +4 -0
- data/lib/mock_redis/set_methods.rb +1 -1
- data/lib/mock_redis/version.rb +1 -1
- data/lib/mock_redis/zset_methods.rb +1 -1
- data/spec/commands/expire_spec.rb +4 -0
- data/spec/commands/srandmember_spec.rb +0 -2
- data/spec/commands/ttl_spec.rb +5 -0
- data/spec/commands/zrevrange_spec.rb +4 -0
- metadata +2 -3
data/CHANGELOG.md
CHANGED
data/lib/mock_redis/database.rb
CHANGED
@@ -199,11 +199,11 @@ class MockRedis
|
|
199
199
|
end
|
200
200
|
|
201
201
|
def expiration(key)
|
202
|
-
expire_times.find {|(_,k)| k == key}.first
|
202
|
+
expire_times.find {|(_,k)| k == key.to_s}.first
|
203
203
|
end
|
204
204
|
|
205
205
|
def has_expiration?(key)
|
206
|
-
expire_times.any? {|(_,k)| k == key}
|
206
|
+
expire_times.any? {|(_,k)| k == key.to_s}
|
207
207
|
end
|
208
208
|
|
209
209
|
def looks_like_integer?(str)
|
@@ -223,14 +223,14 @@ class MockRedis
|
|
223
223
|
|
224
224
|
def remove_expiration(key)
|
225
225
|
expire_times.delete_if do |(t, k)|
|
226
|
-
key == k
|
226
|
+
key.to_s == k
|
227
227
|
end
|
228
228
|
end
|
229
229
|
|
230
230
|
def set_expiration(key, time)
|
231
231
|
remove_expiration(key)
|
232
232
|
|
233
|
-
expire_times << [time, key]
|
233
|
+
expire_times << [time, key.to_s]
|
234
234
|
expire_times.sort! do |a, b|
|
235
235
|
a.first <=> b.first
|
236
236
|
end
|
data/lib/mock_redis/version.rb
CHANGED
@@ -25,6 +25,10 @@ describe "#expire(key, seconds)" do
|
|
25
25
|
end.should raise_error(RuntimeError)
|
26
26
|
end
|
27
27
|
|
28
|
+
it "stringifies key" do
|
29
|
+
@redises.expire(@key.to_sym, 9).should == true
|
30
|
+
end
|
31
|
+
|
28
32
|
context "[mock only]" do
|
29
33
|
# These are mock-only since we can't actually manipulate time in
|
30
34
|
# the real Redis.
|
data/spec/commands/ttl_spec.rb
CHANGED
@@ -14,6 +14,11 @@ describe "#ttl(key)" do
|
|
14
14
|
@redises.ttl('mock-redis-test:nonesuch').should == -1
|
15
15
|
end
|
16
16
|
|
17
|
+
it "stringifies key" do
|
18
|
+
@redises.expire(@key, 9)
|
19
|
+
@redises.ttl(@key.to_sym).should > 0
|
20
|
+
end
|
21
|
+
|
17
22
|
context "[mock only]" do
|
18
23
|
# These are mock-only since we can't actually manipulate time in
|
19
24
|
# the real Redis.
|
@@ -17,6 +17,10 @@ describe "#zrevrange(key, start, stop [, :with_scores => true])" do
|
|
17
17
|
@redises.zrevrange(@key, -2, -1).should == ['Adams', 'Washington']
|
18
18
|
end
|
19
19
|
|
20
|
+
it 'returns empty list when start is too large' do
|
21
|
+
@redises.zrevrange(@key, 5, -1).should == []
|
22
|
+
end
|
23
|
+
|
20
24
|
it "returns the scores when :with_scores is specified" do
|
21
25
|
@redises.zrevrange(@key, 2, 3, :with_scores => true).
|
22
26
|
should == [["Adams", 2.0], ["Washington", 1.0]]
|
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.6.
|
4
|
+
version: 0.6.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-03-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -374,4 +374,3 @@ test_files:
|
|
374
374
|
- spec/support/shared_examples/only_operates_on_zsets.rb
|
375
375
|
- spec/support/shared_examples/sorts_enumerables.rb
|
376
376
|
- spec/transactions_spec.rb
|
377
|
-
has_rdoc:
|