spec/hashes_spec.rb in fakeredis-0.7.0 vs spec/hashes_spec.rb in fakeredis-0.8.0

- old
+ new

@@ -106,10 +106,17 @@ @client.hset("key1", "i2", "val2") expect(@client.hlen("key1")).to eq(2) end + it "should get the string length of the value associated with field in a hash" do + @client.hset("key1", "i1", "val1") + expect(@client.hstrlen("key1", "i1")).to eq(4) + expect(@client.hstrlen("key1", "nonexistent")).to eq(0) + expect(@client.hstrlen("nonexistent", "field")).to eq(0) + end + it "should get the values of all the given hash fields" do @client.hset("key1", "i1", "val1") @client.hset("key1", "i2", "val2") expect(@client.hmget("key1", "i1", "i2", "i3")).to match_array(["val1", "val2", nil]) @@ -118,9 +125,13 @@ expect(@client.hmget("key2", "i1", "i2")).to eq([nil, nil]) end it "should throw an argument error when you don't ask for any keys" do expect { @client.hmget("key1") }.to raise_error(Redis::CommandError) + end + + it "should throw an argument error when the list of keys you ask for is empty" do + expect { @client.hmget("key1", []) }.to raise_error(Redis::CommandError) end it "should reject an empty list of values" do expect { @client.hmset("key") }.to raise_error(Redis::CommandError) expect(@client.exists("key")).to be false