Sha256: 7239832083aab5eac0a7b0e1e4b6c4d11e81bdbf59f6855fbde1dd280975a05a

Contents?: true

Size: 1.06 KB

Versions: 25

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

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

    @redises.zadd(@key, 1, 'one')
    @redises.zadd(@key, 2, 'two')
  end

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

  it 'returns false if member is not present in the set' do
    @redises.zrem(@key, 'nobody home').should == false
  end

  it 'removes member from the set' do
    @redises.zrem(@key, 'one')
    @redises.zrange(@key, 0, -1).should == ['two']
  end

  it 'removes integer member from the set' do
    member = 11
    @redises.zadd(@key, 3, member)
    @redises.zrem(@key, member).should == true
    @redises.zrange(@key, 0, -1).should == %w[one two]
  end

  it 'supports a variable number of arguments' do
    @redises.zrem(@key, %w[one two])
    @redises.zrange(@key, 0, -1).should be_empty
  end

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

  it_should_behave_like 'a zset-only command'
end

Version data entries

25 entries across 25 versions & 1 rubygems

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