Sha256: a2cc56f86e545803c068f901276fe5510421f96d65a1f24eb8e8c33ca42cbd97

Contents?: true

Size: 1.06 KB

Versions: 39

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

describe "#hmset(key, field, value [, field, value ...])" do
  before do
    @key = "mock-redis-test:hmset"
  end

  it "returns 'OK'" do
    @redises.hmset(@key, 'k1', 'v1', 'k2', 'v2').should == "OK"
  end

  it "sets the values" do
    @redises.hmset(@key, 'k1', 'v1', 'k2', 'v2')
    @redises.hmget(@key, 'k1', 'k2').should == %w[v1 v2]
  end

  it "updates an existing hash" do
    @redises.hset(@key, 'foo', 'bar')
    @redises.hmset(@key, 'bert', 'ernie', 'diet', 'coke')

    @redises.hmget(@key, 'foo', 'bert', 'diet').
      should == %w[bar ernie coke]
  end

  it "stores the values as strings" do
    @redises.hmset(@key, 'one', 1)
    @redises.hget(@key, 'one').should == "1"
  end

  it "raises an error if given no fields or values" do
    lambda do
      @redises.hmset(@key)
    end.should raise_error(RuntimeError)
  end

  it "raises an error if given an odd number of fields+values" do
    lambda do
      @redises.hmset(@key, 'k1', 1, 'k2')
    end.should raise_error(RuntimeError)
  end

  it_should_behave_like "a hash-only command"
end

Version data entries

39 entries across 39 versions & 2 rubygems

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