Sha256: 0c52202922f0e8a5f500dac841b81fe60fd47c3660fc35c9daee6e7fe280a882

Contents?: true

Size: 1.1 KB

Versions: 33

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

describe '#lpush(key, value)' do
  before { @key = 'mock-redis-test:57367' }

  it 'returns the new size of the list' do
    @redises.lpush(@key, 'X').should == 1
    @redises.lpush(@key, 'X').should == 2
  end

  it 'creates a new list when run against a nonexistent key' do
    @redises.lpush(@key, 'value')
    @redises.llen(@key).should == 1
  end

  it 'prepends items to the list' do
    @redises.lpush(@key, 'bert')
    @redises.lpush(@key, 'ernie')

    @redises.lindex(@key, 0).should == 'ernie'
    @redises.lindex(@key, 1).should == 'bert'
  end

  it 'stores values as strings' do
    @redises.lpush(@key, 1)
    @redises.lindex(@key, 0).should == '1'
  end

  it 'supports a variable number of arguments' do
    @redises.lpush(@key, [1, 2, 3]).should == 3
    @redises.lindex(@key, 0).should == '3'
    @redises.lindex(@key, 1).should == '2'
    @redises.lindex(@key, 2).should == '1'
  end

  it 'raises an error if an empty array is given' do
    lambda do
      @redises.lpush(@key, [])
    end.should raise_error(Redis::CommandError)
  end

  it_should_behave_like 'a list-only command'
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
mock_redis-0.36.0 spec/commands/lpush_spec.rb
mock_redis-0.35.0 spec/commands/lpush_spec.rb
mock_redis-0.34.0 spec/commands/lpush_spec.rb
mock_redis-0.33.0 spec/commands/lpush_spec.rb
mock_redis-0.32.0 spec/commands/lpush_spec.rb
mock_redis-0.31.0 spec/commands/lpush_spec.rb
mock_redis-0.30.0 spec/commands/lpush_spec.rb
mock_redis-0.29.0 spec/commands/lpush_spec.rb
mock_redis-0.28.0 spec/commands/lpush_spec.rb
mock_redis-0.27.3 spec/commands/lpush_spec.rb
mock_redis-0.27.2 spec/commands/lpush_spec.rb
mock_redis-0.27.1 spec/commands/lpush_spec.rb
mock_redis-0.27.0 spec/commands/lpush_spec.rb
mock_redis-0.26.0 spec/commands/lpush_spec.rb
mock_redis-0.25.0 spec/commands/lpush_spec.rb
mock_redis-0.24.0 spec/commands/lpush_spec.rb
mock_redis-0.23.0 spec/commands/lpush_spec.rb
mock_redis-0.22.0 spec/commands/lpush_spec.rb
mock_redis-0.21.0 spec/commands/lpush_spec.rb
mock_redis-0.20.0 spec/commands/lpush_spec.rb