Sha256: f9ba041d17f7387e1342982cac3c4b786af3482069d7592d9f963fae1689def7

Contents?: true

Size: 1.03 KB

Versions: 26

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

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

  it 'returns the values for those keys' do
    @redises.hmget(@key, 'k1', 'k2').sort.should == %w[v1 v2]
  end

  it 'treats an array as multiple keys' do
    @redises.hmget(@key, %w[k1 k2]).sort.should == %w[v1 v2]
  end

  it 'treats the fielsd as strings' do
    @redises.hset(@key, 1, 'one')
    @redises.hset(@key, 2, 'two')
    @redises.hmget(@key, 1, 2).sort.should == %w[one two]
  end

  it 'returns nils when there are no such fields' do
    @redises.hmget(@key, 'k1', 'mock-redis-test:nonesuch').
      should == ['v1', nil]
  end

  it 'returns nils when there is no such key' do
    @redises.hmget(@key, 'mock-redis-test:nonesuch').should == [nil]
  end

  it 'raises an error if given no fields' do
    lambda do
      @redises.hmget(@key)
    end.should raise_error(Redis::CommandError)
  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.30.0 spec/commands/hmget_spec.rb
mock_redis-0.29.0 spec/commands/hmget_spec.rb
mock_redis-0.28.0 spec/commands/hmget_spec.rb
mock_redis-0.27.3 spec/commands/hmget_spec.rb
mock_redis-0.27.2 spec/commands/hmget_spec.rb
mock_redis-0.27.1 spec/commands/hmget_spec.rb
mock_redis-0.27.0 spec/commands/hmget_spec.rb
mock_redis-0.26.0 spec/commands/hmget_spec.rb
mock_redis-0.25.0 spec/commands/hmget_spec.rb
mock_redis-0.24.0 spec/commands/hmget_spec.rb
mock_redis-0.23.0 spec/commands/hmget_spec.rb
mock_redis-0.22.0 spec/commands/hmget_spec.rb
mock_redis-0.21.0 spec/commands/hmget_spec.rb
mock_redis-0.20.0 spec/commands/hmget_spec.rb
mock_redis-0.19.0 spec/commands/hmget_spec.rb
mock_redis-0.18.0 spec/commands/hmget_spec.rb
mock_redis-0.17.3 spec/commands/hmget_spec.rb
mock_redis-0.17.2 spec/commands/hmget_spec.rb
mock_redis-0.17.1 spec/commands/hmget_spec.rb
mock_redis-0.17.0 spec/commands/hmget_spec.rb