Sha256: 31e4ea61ab0aa7160ad9caaa2941f3a0e181d6f0b8fd3bf299de0a14143e2be6

Contents?: true

Size: 901 Bytes

Versions: 7

Compression:

Stored size: 901 Bytes

Contents

require 'spec_helper'

describe '#del(key [, key, ...])' do
  it "returns the number of keys deleted" do
    @redises.set('mock-redis-test:1', 1)
    @redises.set('mock-redis-test:2', 1)

    @redises.del(
      'mock-redis-test:1',
      'mock-redis-test:2',
      'mock-redis-test:other').should == 2
  end

  it "actually removes the key" do
    @redises.set('mock-redis-test:1', 1)
    @redises.del('mock-redis-test:1')

    @redises.get('mock-redis-test:1').should be_nil
  end

  it "accepts an array of keys" do
    @redises.set('mock-redis-test:1', 1)
    @redises.set('mock-redis-test:2', 2)

    @redises.del(%w[mock-redis-test:1 mock-redis-test:2])

    @redises.get('mock-redis-test:1').should be_nil
    @redises.get('mock-redis-test:2').should be_nil
  end

  it "raises an error if an empty array is given" do
    expect { @redises.del [] }.to raise_error Redis::CommandError
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mock_redis-0.14.1 spec/commands/del_spec.rb
mock_redis-0.14.0 spec/commands/del_spec.rb
mock_redis-0.13.2 spec/commands/del_spec.rb
mock_redis-0.13.1 spec/commands/del_spec.rb
mock_redis-0.13.0 spec/commands/del_spec.rb
mock_redis-0.12.1 spec/commands/del_spec.rb
mock_redis-0.12.0 spec/commands/del_spec.rb