Sha256: 478892cfda93e14d567cd0719f187995f37eed37af3f2a2e7a0d12943bbbe310

Contents?: true

Size: 1.18 KB

Versions: 33

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

describe '#mapped_hmset(key, hash={})' do
  before do
    @key = 'mock-redis-test:mapped_hmset'
  end

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

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

  it 'updates an existing hash' do
    @redises.hmset(@key, 'foo', 'bar')
    @redises.mapped_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.mapped_hmset(@key, 'one' => 1)
    @redises.hget(@key, 'one').should == '1'
  end

  it 'raises an error if given no hash' do
    lambda do
      @redises.mapped_hmset(@key)
    end.should raise_error(ArgumentError)
  end

  it 'raises an error if given a an odd length array' do
    lambda do
      @redises.mapped_hmset(@key, [1])
    end.should raise_error(Redis::CommandError)
  end

  it 'raises an error if given a non-hash value' do
    lambda do
      @redises.mapped_hmset(@key, 1)
    end.should raise_error(NoMethodError)
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

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