Sha256: 6768377334024da885d77cbdba84cffe8571bc71be3f9353a47a5657112f05e9

Contents?: true

Size: 956 Bytes

Versions: 10

Compression:

Stored size: 956 Bytes

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 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 the scores when :with_scores is specified" do
    @redises.zrange(@key, 0, 1, :with_scores => true).
      should == ["Washington", "1", "Adams", "2"]
  end

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

  it_should_behave_like "a zset-only command"
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
mock_redis-0.3.0 spec/commands/zrange_spec.rb
ryansch-mock_redis-0.3.0 spec/commands/zrange_spec.rb
ryansch-mock_redis-0.2.0.2 spec/commands/zrange_spec.rb
ryansch-mock_redis-0.2.0.1 spec/commands/zrange_spec.rb
mock_redis-0.2.0 spec/commands/zrange_spec.rb
mock_redis-0.1.2 spec/commands/zrange_spec.rb
mock_redis-0.1.1 spec/commands/zrange_spec.rb
mock_redis-0.1.0 spec/commands/zrange_spec.rb
mock_redis-0.0.2 spec/commands/zrange_spec.rb
mock_redis-0.0.1 spec/commands/zrange_spec.rb