Sha256: 4e14639f5184fcb129e37d477175338588e91386b1359b85743481b4a141fe15

Contents?: true

Size: 1.12 KB

Versions: 14

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'

describe "#lrange(key, start, stop)" do
  before do
    @key = 'mock-redis-test:68036'

    @redises.lpush(@key, 'v4')
    @redises.lpush(@key, 'v3')
    @redises.lpush(@key, 'v2')
    @redises.lpush(@key, 'v1')
    @redises.lpush(@key, 'v0')
  end

  it "returns a subset of the list inclusive of the right end" do
    @redises.lrange(@key, 0, 2).should == %w[v0 v1 v2]
  end

  it "returns a subset of the list when start and end are strings" do
    @redises.lrange(@key, '0', '2').should == %w[v0 v1 v2]
  end

  it "returns an empty list when start > end" do
    @redises.lrange(@key, 3, 2).should == []
  end

  it "works with negative indices" do
    @redises.lrange(@key, 2, -1).should == %w[v2 v3 v4]
  end

  it "returns [] when run against a nonexistent value" do
    @redises.lrange("mock-redis-test:bogus-key", 0, 1).should == []
  end

  it "returns [] when start is too large" do
    @redises.lrange(@key, 100, 100).should == []
  end

  it "finds the end of the list correctly when end is too large" do
    @redises.lrange(@key, 4, 10).should == %w[v4]
  end

  it_should_behave_like "a list-only command"
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mock_redis-0.10.0 spec/commands/lrange_spec.rb
mock_redis-0.9.0 spec/commands/lrange_spec.rb
mock_redis-0.8.2 spec/commands/lrange_spec.rb
mock_redis-0.8.1 spec/commands/lrange_spec.rb
mock_redis-0.8.0 spec/commands/lrange_spec.rb
mock_redis-0.7.0 spec/commands/lrange_spec.rb
mock_redis-0.6.6 spec/commands/lrange_spec.rb
mock_redis-0.6.5 spec/commands/lrange_spec.rb
mock_redis-0.6.4 spec/commands/lrange_spec.rb
mock_redis-0.6.3 spec/commands/lrange_spec.rb
mock_redis-0.6.2 spec/commands/lrange_spec.rb
mock_redis-0.6.1 spec/commands/lrange_spec.rb
mock_redis-0.6.0 spec/commands/lrange_spec.rb
mock_redis-0.5.5 spec/commands/lrange_spec.rb