Sha256: 6b02777fd4232bcbc9f1abb9f266245502c2e26ebd17e13e132c189d4fc5df69

Contents?: true

Size: 1.07 KB

Versions: 19

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe '#srem(key, member)' do
  before do
    @key = 'mock-redis-test:srem'

    @redises.sadd(@key, 'bert')
    @redises.sadd(@key, 'ernie')
  end

  it 'returns true if member is in the set' do
    @redises.srem(@key, 'bert').should == true
  end

  it 'returns false if member is not in the set' do
    @redises.srem(@key, 'cookiemonster').should == false
  end

  it 'removes member from the set' do
    @redises.srem(@key, 'ernie')
    @redises.smembers(@key).should == ['bert']
  end

  it 'stringifies member' do
    @redises.sadd(@key, '1')
    @redises.srem(@key, 1).should == true
  end

  it 'cleans up empty sets' do
    @redises.smembers(@key).each { |m| @redises.srem(@key, m) }
    @redises.get(@key).should be_nil
  end

  it 'supports a variable number of arguments' do
    @redises.srem(@key, %w[bert ernie]).should == 2
    @redises.get(@key).should be_nil
  end

  it 'allow passing an array of integers as argument' do
    @redises.sadd(@key, %w[1 2])
    @redises.srem(@key, [1, 2]).should == 2
  end

  it_should_behave_like 'a set-only command'
end

Version data entries

19 entries across 19 versions & 1 rubygems

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