Sha256: 5fec27158a8f862df9ada2acd024f6e4efda69ee82267a625ce1040e625e20c3

Contents?: true

Size: 916 Bytes

Versions: 20

Compression:

Stored size: 916 Bytes

Contents

require 'spec_helper'

describe '#spop(key)' do
  before do
    @key = 'mock-redis-test:spop'

    @redises.sadd(@key, 'value')
  end

  it 'returns a member of the set' do
    @redises.spop(@key).should == 'value'
  end

  it 'removes a member of the set' do
    @redises.spop(@key)
    @redises.smembers(@key).should == []
  end

  it 'returns nil if the set is empty' do
    @redises.spop(@key)
    @redises.spop(@key).should be_nil
  end

  it 'returns an array if count is not nil' do
    @redises.sadd(@key, 'value2')
    @redises.spop(@key, 2).should == %w[value value2]
  end

  it 'returns only whats in the set' do
    @redises.spop(@key, 2).should == ['value']
    @redises.smembers(@key).should == []
  end

  it 'returns an empty array if count is not nil and the set it empty' do
    @redises.spop(@key)
    @redises.spop(@key, 100).should == []
  end

  it_should_behave_like 'a set-only command'
end

Version data entries

20 entries across 20 versions & 1 rubygems

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