Sha256: efe1520ad6932cc535f152ff31b87afe71ee5816f31711565eda7ddb3da734bc

Contents?: true

Size: 1.05 KB

Versions: 25

Compression:

Stored size: 1.05 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 be_true
  end

  it "responds with false when newkey exists" do
    @redises.set(@newkey, 'monkey')
    @redises.renamenx(@key, @newkey).should be_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 "raises an error when key == newkey" do
    lambda do
      @redises.renamenx(@key, @key)
    end.should raise_error(RuntimeError)
  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

25 entries across 25 versions & 1 rubygems

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