Sha256: bc5969b6936a55c8961e2b27405c3721aabaf7f7cbd5eb7ed16faa50046ac7ae

Contents?: true

Size: 890 Bytes

Versions: 21

Compression:

Stored size: 890 Bytes

Contents

require 'spec_helper'

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

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

  it "responds with 'OK'" do
    @redises.rename(@key, @newkey).should == 'OK'
  end

  it "moves the data" do
    @redises.rename(@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.rename(@key, @key)
    end.should raise_error(RuntimeError)
  end

  it "overwrites any existing value at newkey" do
    @redises.set(@newkey, "rab")
    @redises.rename(@key, @newkey)
    @redises.get(@newkey).should == "oof"
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
mock_redis-0.12.0 spec/commands/rename_spec.rb
mock_redis-0.11.0 spec/commands/rename_spec.rb
mock_redis-0.10.0 spec/commands/rename_spec.rb
mock_redis-0.9.0 spec/commands/rename_spec.rb
mock_redis-0.8.2 spec/commands/rename_spec.rb
mock_redis-0.8.1 spec/commands/rename_spec.rb
mock_redis-0.8.0 spec/commands/rename_spec.rb
mock_redis-0.7.0 spec/commands/rename_spec.rb
mock_redis-0.6.6 spec/commands/rename_spec.rb
mock_redis-0.6.5 spec/commands/rename_spec.rb
mock_redis-0.6.4 spec/commands/rename_spec.rb
mock_redis-0.6.3 spec/commands/rename_spec.rb
mock_redis-0.6.2 spec/commands/rename_spec.rb
mock_redis-0.6.1 spec/commands/rename_spec.rb
mock_redis-0.6.0 spec/commands/rename_spec.rb
mock_redis-0.5.5 spec/commands/rename_spec.rb
mock_redis-0.5.4 spec/commands/rename_spec.rb
mock_redis-0.5.3 spec/commands/rename_spec.rb
mock_redis-0.5.2 spec/commands/rename_spec.rb
mock_redis-0.5.1 spec/commands/rename_spec.rb