Sha256: b5f41f49490ab0ce8321708351403726e19d06546a798e5cbe247784997b41e0

Contents?: true

Size: 776 Bytes

Versions: 1

Compression:

Stored size: 776 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(RuntimeError)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mock_redis-0.15.0 spec/commands/mget_spec.rb