Sha256: 797ea363c1e1d70507f19f9173bbae4ef7e858285a9b14cf994808376118dda8

Contents?: true

Size: 706 Bytes

Versions: 29

Compression:

Stored size: 706 Bytes

Contents

require 'spec_helper'

describe '#rpop(key)' do
  before { @key = 'mock-redis-test:43093' }

  it 'returns and removes the first element of a list' do
    @redises.lpush(@key, 1)
    @redises.lpush(@key, 2)

    @redises.rpop(@key).should == '1'

    @redises.llen(@key).should == 1
  end

  it 'returns nil if the list is empty' do
    @redises.lpush(@key, 'foo')
    @redises.rpop(@key)

    @redises.rpop(@key).should be_nil
  end

  it 'returns nil for nonexistent values' do
    @redises.rpop(@key).should be_nil
  end

  it 'removes empty lists' do
    @redises.lpush(@key, 'foo')
    @redises.rpop(@key)

    @redises.get(@key).should be_nil
  end

  it_should_behave_like 'a list-only command'
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
mock_redis-0.32.0 spec/commands/rpop_spec.rb
mock_redis-0.31.0 spec/commands/rpop_spec.rb
mock_redis-0.30.0 spec/commands/rpop_spec.rb
mock_redis-0.29.0 spec/commands/rpop_spec.rb
mock_redis-0.28.0 spec/commands/rpop_spec.rb
mock_redis-0.27.3 spec/commands/rpop_spec.rb
mock_redis-0.27.2 spec/commands/rpop_spec.rb
mock_redis-0.27.1 spec/commands/rpop_spec.rb
mock_redis-0.27.0 spec/commands/rpop_spec.rb
mock_redis-0.26.0 spec/commands/rpop_spec.rb
mock_redis-0.25.0 spec/commands/rpop_spec.rb
mock_redis-0.24.0 spec/commands/rpop_spec.rb
mock_redis-0.23.0 spec/commands/rpop_spec.rb
mock_redis-0.22.0 spec/commands/rpop_spec.rb
mock_redis-0.21.0 spec/commands/rpop_spec.rb
mock_redis-0.20.0 spec/commands/rpop_spec.rb
mock_redis-0.19.0 spec/commands/rpop_spec.rb
mock_redis-0.18.0 spec/commands/rpop_spec.rb
mock_redis-0.17.3 spec/commands/rpop_spec.rb
mock_redis-0.17.2 spec/commands/rpop_spec.rb