Sha256: 61cea1671974b372009e1d6b33a94bdc7c734cb1fbde503b50d07416ec1ebb1f

Contents?: true

Size: 1.01 KB

Versions: 22

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

describe '#renamenx(key, newkey)' do
  before do
    @key = 'mock-redis-test:renamenx:key'
    @newkey = 'mock-redis-test:renamenx:newkey'

    @redises.set(@key, 'oof')
  end

  it 'responds with true when newkey does not exist' do
    @redises.renamenx(@key, @newkey).should == true
  end

  it 'responds with false when newkey exists' do
    @redises.set(@newkey, 'monkey')
    @redises.renamenx(@key, @newkey).should == false
  end

  it 'moves the data' do
    @redises.renamenx(@key, @newkey)
    @redises.get(@newkey).should == 'oof'
  end

  it 'raises an error when the source key is nonexistant' do
    @redises.del(@key)
    lambda do
      @redises.rename(@key, @newkey)
    end.should raise_error(Redis::CommandError)
  end

  it 'returns false when key == newkey' do
    @redises.renamenx(@key, @key).should == false
  end

  it 'leaves any existing value at newkey alone' do
    @redises.set(@newkey, 'rab')
    @redises.renamenx(@key, @newkey)
    @redises.get(@newkey).should == 'rab'
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

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