spec/keys_spec.rb in fakeredis-0.4.0 vs spec/keys_spec.rb in fakeredis-0.4.1
- old
+ new
@@ -13,10 +13,24 @@
@client.del("key1", "key2")
@client.get("key1").should == nil
end
+ it "should delete multiple keys" do
+ @client.set("key1", "1")
+ @client.set("key2", "2")
+ @client.del(["key1", "key2"])
+
+ @client.get("key1").should be == nil
+ @client.get("key2").should be == nil
+ end
+
+ it "should error deleting no keys" do
+ lambda { @client.del }.should raise_error(Redis::CommandError, "ERR wrong number of arguments for 'del' command")
+ lambda { @client.del [] }.should raise_error(Redis::CommandError, "ERR wrong number of arguments for 'del' command")
+ end
+
it "should determine if a key exists" do
@client.set("key1", "1")
@client.exists("key1").should == true
@client.exists("key2").should == false
@@ -86,15 +100,15 @@
@client.set("key:b", "2")
@client.set("key:c", "3")
@client.set("akeyd", "4")
@client.set("key1", "5")
- @client.keys("key:").should =~ ["key:a", "key:b", "key:c"]
+ @client.keys("key:*").should =~ ["key:a", "key:b", "key:c"]
end
it "should remove the expiration from a key" do
@client.set("key1", "1")
- @client.expireat("key1", Time.now.to_i)
+ @client.expireat("key1", Time.now.to_i + 1)
@client.persist("key1").should == true
@client.persist("key1").should == false
@client.ttl("key1").should == -1
end