Sha256: 72214500385d8779397479c255b1996560f5966be0611bda0b6f5a034c68ba98

Contents?: true

Size: 1.1 KB

Versions: 11

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

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

  it 'returns the new size of the list' do
    @redises.lpush(@key, 'X')

    @redises.rpushx(@key, 'X').should == 2
    @redises.rpushx(@key, 'X').should == 3
  end

  it 'does nothing when run against a nonexistent key' do
    @redises.rpushx(@key, 'value')
    @redises.get(@key).should be_nil
  end

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

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

  it 'stores values as strings' do
    @redises.rpush(@key, 1)
    @redises.rpushx(@key, 2)
    @redises.lindex(@key, 1).should == '2'
  end

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

  it 'raises an error if an array of more than one item is given' do
    lambda do
      @redises.rpushx(@key, [1, 2])
    end.should raise_error(Redis::CommandError)
  end

  it_should_behave_like 'a list-only command'
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mock_redis-0.17.3 spec/commands/rpushx_spec.rb
mock_redis-0.17.2 spec/commands/rpushx_spec.rb
mock_redis-0.17.1 spec/commands/rpushx_spec.rb
mock_redis-0.17.0 spec/commands/rpushx_spec.rb
mock_redis-0.16.1 spec/commands/rpushx_spec.rb
mock_redis-0.16.0 spec/commands/rpushx_spec.rb
mock_redis-0.15.4 spec/commands/rpushx_spec.rb
mock_redis-0.15.3 spec/commands/rpushx_spec.rb
mock_redis-0.15.2 spec/commands/rpushx_spec.rb
mock_redis-0.15.1 spec/commands/rpushx_spec.rb
mock_redis-0.15.0 spec/commands/rpushx_spec.rb