Skip to content

Commit

Permalink
Merge 7966db3 into 386a9cb
Browse files Browse the repository at this point in the history
  • Loading branch information
sinclairtarget committed Apr 1, 2017
2 parents 386a9cb + 7966db3 commit 10cd851
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mock_redis/zset_methods.rb
Expand Up @@ -119,7 +119,7 @@ def zinterstore(destination, keys, options = {})
def zrange(key, start, stop, options = {})
with_zset_at(key) do |z|
start = [start.to_i, -z.sorted.size].max
stop = [stop.to_i, -z.sorted.size].max
stop = stop.to_i
to_response(z.sorted[start..stop] || [], options)
end
end
Expand Down
4 changes: 4 additions & 0 deletions spec/commands/zrange_spec.rb
Expand Up @@ -58,6 +58,10 @@
@redises.zrange(@key, 1, -5).should == []
end

it 'returns empty list when start is 0 with negative end out of bounds' do
@redises.zrange(@key, 0, -5).should == []
end

it 'returns correct subset when start is in bounds with negative end in bounds' do
@redises.zrange(@key, 1, -1).should == %w[Adams Jefferson Madison]
end
Expand Down

0 comments on commit 10cd851

Please sign in to comment.