Sha256: 82840df84e76654b81050b53d53cd72e1e50f2f87b81d983030f934aaf308a27

Contents?: true

Size: 1.17 KB

Versions: 22

Compression:

Stored size: 1.17 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
    @redises.lpush(@key, 'X')
    lambda do
      @redises.rpushx(@key, [])
    end.should raise_error(Redis::CommandError)
  end

  it 'stores multiple items if an array of more than one item is given' do
    @redises.lpush(@key, 'X')
    @redises.rpushx(@key, [1, 2]).should == 3
    @redises.lrange(@key, 0, -1).should == %w[X 1 2]
  end

  it_should_behave_like 'a list-only command'
end

Version data entries

22 entries across 22 versions & 1 rubygems

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