Sha256: 73a02f7695826fd6b87663c92af502c6cfceee8fd51c1e45827c58bf0448d7e7

Contents?: true

Size: 1.07 KB

Versions: 32

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe '#lset(key, index, value)' do
  before do
    @key = 'mock-redis-test:21522'

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

  it "returns 'OK'" do
    @redises.lset(@key, 0, 'newthing').should == 'OK'
  end

  it "sets the list's value at index to value" do
    @redises.lset(@key, 0, 'newthing')
    @redises.lindex(@key, 0).should == 'newthing'
  end

  it "sets the list's value at index to value when the index is a string" do
    @redises.lset(@key, '0', 'newthing')
    @redises.lindex(@key, 0).should == 'newthing'
  end

  it 'stringifies value' do
    @redises.lset(@key, 0, 12_345)
    @redises.lindex(@key, 0).should == '12345'
  end

  it 'raises an exception for nonexistent keys' do
    lambda do
      @redises.lset('mock-redis-test:bogus-key', 100, 'value')
    end.should raise_error(Redis::CommandError)
  end

  it 'raises an exception for out-of-range indices' do
    lambda do
      @redises.lset(@key, 100, 'value')
    end.should raise_error(Redis::CommandError)
  end

  it_should_behave_like 'a list-only command'
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
mock_redis-0.19.0 spec/commands/lset_spec.rb
mock_redis-0.18.0 spec/commands/lset_spec.rb
mock_redis-0.17.3 spec/commands/lset_spec.rb
mock_redis-0.17.2 spec/commands/lset_spec.rb
mock_redis-0.17.1 spec/commands/lset_spec.rb
mock_redis-0.17.0 spec/commands/lset_spec.rb
mock_redis-0.16.1 spec/commands/lset_spec.rb
mock_redis-0.16.0 spec/commands/lset_spec.rb
mock_redis-0.15.4 spec/commands/lset_spec.rb
mock_redis-0.15.3 spec/commands/lset_spec.rb
mock_redis-0.15.2 spec/commands/lset_spec.rb
mock_redis-0.15.1 spec/commands/lset_spec.rb