Sha256: f03ff3003a80e251f25167de7705dda49c383867aaf1a48c8c5fb112c6bbda06

Contents?: true

Size: 788 Bytes

Versions: 15

Compression:

Stored size: 788 Bytes

Contents

require 'spec_helper'

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

  it "returns the (key, value) pairs stored in the hash" do
    @redises.hgetall(@key).should == {
      'k1' => 'v1',
      'k2' => 'v2',
    }
  end

  it "returns [] when there is no such key" do
    @redises.hgetall('mock-redis-test:nonesuch').should == {}
  end

  it "doesn't return a mutable reference to the returned data" do
    mr = MockRedis.new
    mr.hset(@key, 'k1', 'v1')
    mr.hset(@key, 'k2', 'v2')
    hash =  mr.hgetall(@key)
    hash['dont'] = 'mutate'
    new_hash = mr.hgetall(@key)
    new_hash.keys.sort.should == ['k1', 'k2']
  end

  it_should_behave_like "a hash-only command"
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
mock_redis-0.14.1 spec/commands/hgetall_spec.rb
mock_redis-0.14.0 spec/commands/hgetall_spec.rb
mock_redis-0.13.2 spec/commands/hgetall_spec.rb
mock_redis-0.13.1 spec/commands/hgetall_spec.rb
mock_redis-0.13.0 spec/commands/hgetall_spec.rb
mock_redis-0.12.1 spec/commands/hgetall_spec.rb
mock_redis-0.12.0 spec/commands/hgetall_spec.rb
mock_redis-0.11.0 spec/commands/hgetall_spec.rb
mock_redis-0.10.0 spec/commands/hgetall_spec.rb
mock_redis-0.9.0 spec/commands/hgetall_spec.rb
mock_redis-0.8.2 spec/commands/hgetall_spec.rb
mock_redis-0.8.1 spec/commands/hgetall_spec.rb
mock_redis-0.8.0 spec/commands/hgetall_spec.rb
mock_redis-0.7.0 spec/commands/hgetall_spec.rb
mock_redis-0.6.6 spec/commands/hgetall_spec.rb