mock_redis 0.17.1 → 0.17.2

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: a55e7d747d39e4c40aedd4b13974ea1ba8fb78a3
4
- data.tar.gz: b5efc0805cac7734fa78403f18b4ee4253866197
3
+ metadata.gz: a6964254237dcb85924a41b08802b43875d9285d
4
+ data.tar.gz: 96914898547b94bea6e7fcedd59275473f3bea2e
5
5
  SHA512:
6
- metadata.gz: a0c1277f32ded504822a15d589c0c262d872593afe6a98e100cdc05e06ff5e04a39e5b8899089656de0f061dc197d632ce954550bae4fb61095df359f27bccef
7
- data.tar.gz: 33183c7e84dc6d0ebc9990b44bb0ada35bbaca1a90a0ee801f94e8d240419cdcf108b9c1bf861a27f4efbc1e03a9f83052ddd3fe3c6da8a66849f71212d9e677
6
+ metadata.gz: 6c955b02cf5fd7c4b3b251a29fc6879d7156ea16875367041a24833f3812c11448ba011a9210e221fb89299ec50efa969913c0c9c774522fd31d3e21443f7380
7
+ data.tar.gz: 600fe03cfd32d108ae506e651026b5372d5a987511a92a8190b7b438d7360fd982645effbcac88668f11815fa5c072e111726b3d0529a340e0654cae37147259
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # MockRedis Changelog
2
2
 
3
+ ### master (unreleased)
4
+
5
+ ### 0.17.2
6
+
7
+ * Allow negative out-of-bounds start and stop in `zrange`
8
+
3
9
  ### 0.17.1
4
10
 
5
11
  * Flatten args list passed to `hmset`
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  class MockRedis
5
- VERSION = '0.17.1'.freeze
5
+ VERSION = '0.17.2'.freeze
6
6
  end
@@ -118,7 +118,9 @@ class MockRedis
118
118
 
119
119
  def zrange(key, start, stop, options = {})
120
120
  with_zset_at(key) do |z|
121
- to_response(z.sorted[start.to_i..stop.to_i] || [], options)
121
+ start = [start.to_i, -z.sorted.size].max
122
+ stop = [stop.to_i, -z.sorted.size].max
123
+ to_response(z.sorted[start..stop] || [], options)
122
124
  end
123
125
  end
124
126
 
@@ -46,6 +46,22 @@ describe '#zrange(key, start, stop [, :with_scores => true])' do
46
46
  @redises.zrange(@key, 5, -1).should == []
47
47
  end
48
48
 
49
+ it 'returns entire list when start is out of bounds with negative end in bounds' do
50
+ @redises.zrange(@key, -5, -1).should == %w[Washington Adams Jefferson Madison]
51
+ end
52
+
53
+ it 'returns correct subset when start is out of bounds with positive end in bounds' do
54
+ @redises.zrange(@key, -5, 1).should == %w[Washington Adams]
55
+ end
56
+
57
+ it 'returns empty list when start is in bounds with negative end out of bounds' do
58
+ @redises.zrange(@key, 1, -5).should == []
59
+ end
60
+
61
+ it 'returns correct subset when start is in bounds with negative end in bounds' do
62
+ @redises.zrange(@key, 1, -1).should == %w[Adams Jefferson Madison]
63
+ end
64
+
49
65
  it 'returns the scores when :with_scores is specified' do
50
66
  @redises.zrange(@key, 0, 1, :with_scores => true).
51
67
  should == [['Washington', 1.0], ['Adams', 2.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.17.1
4
+ version: 0.17.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brigade Engineering
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-11-16 00:00:00.000000000 Z
12
+ date: 2017-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -281,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
281
  version: '0'
282
282
  requirements: []
283
283
  rubyforge_project:
284
- rubygems_version: 2.5.1
284
+ rubygems_version: 2.4.5.1
285
285
  signing_key:
286
286
  specification_version: 4
287
287
  summary: Redis mock that just lives in memory; useful for testing.
@@ -432,3 +432,4 @@ test_files:
432
432
  - spec/support/shared_examples/only_operates_on_zsets.rb
433
433
  - spec/support/shared_examples/sorts_enumerables.rb
434
434
  - spec/transactions_spec.rb
435
+ has_rdoc: