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