Sha256: 257d581a925679bfba6148fa3dcffbd37552ec26d9aeed4903c30ac640d26955

Contents?: true

Size: 784 Bytes

Versions: 31

Compression:

Stored size: 784 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 == %w[k1 k2]
  end

  it_should_behave_like 'a hash-only command'
end

Version data entries

31 entries across 31 versions & 1 rubygems

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