Sha256: 210928479eb5f39ce1b45895d9f52662b03fa0d0437a11cf3d7a83577386a1d9

Contents?: true

Size: 783 Bytes

Versions: 12

Compression:

Stored size: 783 Bytes

Contents

require 'spec_helper'

describe '#mget(key [, key, ...])' do
  before do
    @key1 = 'mock-redis-test:mget1'
    @key2 = 'mock-redis-test:mget2'

    @redises.set(@key1, 1)
    @redises.set(@key2, 2)
  end

  it 'returns an array of values' do
    @redises.mget(@key1, @key2).should == %w[1 2]
  end

  it 'returns nil for missing keys' do
    @redises.mget(@key1, 'mock-redis-test:not-found', @key2).
      should == ['1', nil, '2']
  end

  it 'returns nil for non-string keys' do
    list = 'mock-redis-test:mget-list'

    @redises.lpush(list, 'bork bork bork')

    @redises.mget(@key1, @key2, list).should == ['1', '2', nil]
  end

  it 'raises an error if you pass it 0 arguments' do
    lambda do
      @redises.mget
    end.should raise_error(Redis::CommandError)
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
mock_redis-0.19.0 spec/commands/mget_spec.rb
mock_redis-0.18.0 spec/commands/mget_spec.rb
mock_redis-0.17.3 spec/commands/mget_spec.rb
mock_redis-0.17.2 spec/commands/mget_spec.rb
mock_redis-0.17.1 spec/commands/mget_spec.rb
mock_redis-0.17.0 spec/commands/mget_spec.rb
mock_redis-0.16.1 spec/commands/mget_spec.rb
mock_redis-0.16.0 spec/commands/mget_spec.rb
mock_redis-0.15.4 spec/commands/mget_spec.rb
mock_redis-0.15.3 spec/commands/mget_spec.rb
mock_redis-0.15.2 spec/commands/mget_spec.rb
mock_redis-0.15.1 spec/commands/mget_spec.rb