Sha256: 40c0c71f3f80e614066ad6c744141b73ad7c2a605686450ed3e3ab3944354048

Contents?: true

Size: 596 Bytes

Versions: 37

Compression:

Stored size: 596 Bytes

Contents

require 'spec_helper'

describe '#setnx(key, value)' do
  before { @key = 'mock-redis-test:setnx' }

  it "returns true if the key was absent" do
    @redises.setnx(@key, 1).should be_true
  end

  it "returns false if the key was present" do
    @redises.set(@key, 2)
    @redises.setnx(@key, 1).should be_false
  end

  it "sets the value if missing" do
    @redises.setnx(@key, 'value')
    @redises.get(@key).should == 'value'
  end

  it "does nothing if the value is present" do
    @redises.set(@key, 'old')
    @redises.setnx(@key, 'new')
    @redises.get(@key).should == 'old'
  end
end

Version data entries

37 entries across 37 versions & 2 rubygems

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