Sha256: 3f42718d36347eda5805065191809616dfe33bc845307da83b1f934707000d76

Contents?: true

Size: 939 Bytes

Versions: 28

Compression:

Stored size: 939 Bytes

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 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(RuntimeError)
  end

  it_should_behave_like "a hash-only command"
end

Version data entries

28 entries across 28 versions & 1 rubygems

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