Sha256: 03b98f016b926f0dfd5f6a0df5c0a876ab52410d5840e8f6e498bd1a31b522c5

Contents?: true

Size: 1.09 KB

Versions: 26

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

describe "#hdel(key, field)" do
  before do
    @key = "mock-redis-test:hdel"
    @redises.hset(@key, 'k1', 'v1')
    @redises.hset(@key, 'k2', 'v2')
  end

  it "returns 1 when it removes a field" do
    @redises.hdel(@key, 'k1').should == 1
  end

  it "returns 0 when it does not remove a field" do
    @redises.hdel(@key, 'nonesuch').should == 0
  end

  it "actually removes the field" do
    @redises.hdel(@key, 'k1')
    @redises.hget(@key, 'k1').should be_nil
  end

  it "treats the field as a string" do
    field = 2
    @redises.hset(@key, field, 'two')
    @redises.hdel(@key, field)
    @redises.hget(@key, field).should be_nil
  end

  it "removes only the field specified" do
    @redises.hdel(@key, 'k1')
    @redises.hget(@key, 'k2').should == 'v2'
  end

  it "cleans up empty hashes" do
    @redises.hdel(@key, 'k1')
    @redises.hdel(@key, 'k2')
    @redises.get(@key).should be_nil
  end

  it "supports a variable number of arguments" do
    @redises.hdel(@key, ['k1', 'k2'])
    @redises.get(@key).should be_nil
  end

  it_should_behave_like "a hash-only command"
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
mock_redis-0.14.0 spec/commands/hdel_spec.rb
mock_redis-0.13.2 spec/commands/hdel_spec.rb
mock_redis-0.13.1 spec/commands/hdel_spec.rb
mock_redis-0.13.0 spec/commands/hdel_spec.rb
mock_redis-0.12.1 spec/commands/hdel_spec.rb
mock_redis-0.12.0 spec/commands/hdel_spec.rb
mock_redis-0.11.0 spec/commands/hdel_spec.rb
mock_redis-0.10.0 spec/commands/hdel_spec.rb
mock_redis-0.9.0 spec/commands/hdel_spec.rb
mock_redis-0.8.2 spec/commands/hdel_spec.rb
mock_redis-0.8.1 spec/commands/hdel_spec.rb
mock_redis-0.8.0 spec/commands/hdel_spec.rb
mock_redis-0.7.0 spec/commands/hdel_spec.rb
mock_redis-0.6.6 spec/commands/hdel_spec.rb
mock_redis-0.6.5 spec/commands/hdel_spec.rb
mock_redis-0.6.4 spec/commands/hdel_spec.rb
mock_redis-0.6.3 spec/commands/hdel_spec.rb
mock_redis-0.6.2 spec/commands/hdel_spec.rb
mock_redis-0.6.1 spec/commands/hdel_spec.rb
mock_redis-0.6.0 spec/commands/hdel_spec.rb