Sha256: 64c48282e4177c56c249aec780a852040bbac781279066cefee1d8e7f5ff5a29

Contents?: true

Size: 1.06 KB

Versions: 25

Compression:

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

  it "raises an error if given 0 arguments" do
    lambda do
      @redises.msetnx()
    end.should raise_error(RuntimeError)
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
mock_redis-0.13.2 spec/commands/msetnx_spec.rb
mock_redis-0.13.1 spec/commands/msetnx_spec.rb
mock_redis-0.13.0 spec/commands/msetnx_spec.rb
mock_redis-0.12.1 spec/commands/msetnx_spec.rb
mock_redis-0.12.0 spec/commands/msetnx_spec.rb
mock_redis-0.11.0 spec/commands/msetnx_spec.rb
mock_redis-0.10.0 spec/commands/msetnx_spec.rb
mock_redis-0.9.0 spec/commands/msetnx_spec.rb
mock_redis-0.8.2 spec/commands/msetnx_spec.rb
mock_redis-0.8.1 spec/commands/msetnx_spec.rb
mock_redis-0.8.0 spec/commands/msetnx_spec.rb
mock_redis-0.7.0 spec/commands/msetnx_spec.rb
mock_redis-0.6.6 spec/commands/msetnx_spec.rb
mock_redis-0.6.5 spec/commands/msetnx_spec.rb
mock_redis-0.6.4 spec/commands/msetnx_spec.rb
mock_redis-0.6.3 spec/commands/msetnx_spec.rb
mock_redis-0.6.2 spec/commands/msetnx_spec.rb
mock_redis-0.6.1 spec/commands/msetnx_spec.rb
mock_redis-0.6.0 spec/commands/msetnx_spec.rb
mock_redis-0.5.5 spec/commands/msetnx_spec.rb