Sha256: 0384ffe76adef17c2081d14e9612b6819a0b52cadd64b36b63f024b98f590d91

Contents?: true

Size: 1.07 KB

Versions: 32

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe '#msetnx(key, value [, key, value, ...])' do
  before do
    @key1 = 'mock-redis-test:msetnx1'
    @key2 = 'mock-redis-test:msetnx2'
  end

  it 'responds with 1 if any keys were set' do
    @redises.msetnx(@key1, 1).should == true
  end

  it 'sets the values' do
    @redises.msetnx(@key1, 'value1', @key2, 'value2')
    @redises.mget(@key1, @key2).should == %w[value1 value2]
  end

  it 'does nothing if any value is already set' do
    @redises.set(@key1, 'old1')
    @redises.msetnx(@key1, 'value1', @key2, 'value2')
    @redises.mget(@key1, @key2).should == ['old1', nil]
  end

  it 'responds with 0 if any value is already set' do
    @redises.set(@key1, 'old1')
    @redises.msetnx(@key1, 'value1', @key2, 'value2').should == false
  end

  it 'raises an error if given an odd number of arguments' do
    lambda do
      @redises.msetnx(@key1, 'value1', @key2)
    end.should raise_error(Redis::CommandError)
  end

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

Version data entries

32 entries across 32 versions & 1 rubygems

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