spec/hashes_spec.rb in fakeredis-0.4.2 vs spec/hashes_spec.rb in fakeredis-0.4.3
- old
+ new
@@ -151,7 +151,32 @@
@client.hset("key1", "k2", "val2")
@client.hvals("key1").should =~ ["val1", "val2"]
end
+ it "should accept a list of array pairs as arguments and not throw an invalid argument number error" do
+ @client.hmset("key1", [:k1, "val1"], [:k2, "val2"], [:k3, "val3"])
+ @client.hget("key1", :k1).should be == "val1"
+ @client.hget("key1", :k2).should be == "val2"
+ @client.hget("key1", :k3).should be == "val3"
+ end
+
+ it "should reject a list of arrays that contain an invalid number of arguments" do
+ expect { @client.hmset("key1", [:k1, "val1"], [:k2, "val2", "bogus val"]) }.to raise_error(Redis::CommandError, "ERR wrong number of arguments for HMSET")
+ end
+
+ it "should convert a integer field name to string for hdel" do
+ @client.hset("key1", "1", 1)
+ @client.hdel("key1", 1).should be(1)
+ end
+
+ it "should convert a integer field name to string for hexists" do
+ @client.hset("key1", "1", 1)
+ @client.hexists("key1", 1).should be_true
+ end
+
+ it "should convert a integer field name to string for hincrby" do
+ @client.hset("key1", 1, 0)
+ @client.hincrby("key1", 1, 1).should be(1)
+ end
end
end