Sha256: 513851223ee943d5754c568462515a2ee39ad8716655b8c4342f74818667ef30

Contents?: true

Size: 1.18 KB

Versions: 19

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

describe "#zrange(key, start, stop [, :with_scores => true])" do
  before do
    @key = 'mock-redis-test:zrange'
    @redises.zadd(@key, 1, 'Washington')
    @redises.zadd(@key, 2, 'Adams')
    @redises.zadd(@key, 3, 'Jefferson')
    @redises.zadd(@key, 4, 'Madison')
  end

  it "returns the elements when the range is given as strings" do
    @redises.zrange(@key, "0", "1").should == ['Washington', 'Adams']
  end

  it "returns the elements in order by score" do
    @redises.zrange(@key, 0, 1).should == ['Washington', 'Adams']
  end

  it "returns the elements in order by score (negative indices)" do
    @redises.zrange(@key, -2, -1).should == ['Jefferson', 'Madison']
  end

  it 'returns empty list when start is too large' do
    @redises.zrange(@key, 5, -1).should == []
  end

  it "returns the scores when :with_scores is specified" do
    @redises.zrange(@key, 0, 1, :with_scores => true).
      should == [["Washington", 1.0], ["Adams", 2.0]]
  end

  it "returns the scores when :withscores is specified" do
    @redises.zrange(@key, 0, 1, :withscores => true).
      should == [["Washington", 1.0], ["Adams", 2.0]]
  end

  it_should_behave_like "a zset-only command"
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
mock_redis-0.10.0 spec/commands/zrange_spec.rb
mock_redis-0.9.0 spec/commands/zrange_spec.rb
mock_redis-0.8.2 spec/commands/zrange_spec.rb
mock_redis-0.8.1 spec/commands/zrange_spec.rb
mock_redis-0.8.0 spec/commands/zrange_spec.rb
mock_redis-0.7.0 spec/commands/zrange_spec.rb
mock_redis-0.6.6 spec/commands/zrange_spec.rb
mock_redis-0.6.5 spec/commands/zrange_spec.rb
mock_redis-0.6.4 spec/commands/zrange_spec.rb
mock_redis-0.6.3 spec/commands/zrange_spec.rb
mock_redis-0.6.2 spec/commands/zrange_spec.rb
mock_redis-0.6.1 spec/commands/zrange_spec.rb
mock_redis-0.6.0 spec/commands/zrange_spec.rb
mock_redis-0.5.5 spec/commands/zrange_spec.rb
mock_redis-0.5.4 spec/commands/zrange_spec.rb
mock_redis-0.5.3 spec/commands/zrange_spec.rb
mock_redis-0.5.2 spec/commands/zrange_spec.rb
mock_redis-0.5.1 spec/commands/zrange_spec.rb
mock_redis-0.5.0 spec/commands/zrange_spec.rb