spec/strings_spec.rb in fakeredis-0.8.0 vs spec/strings_spec.rb in fakeredis-0.9.0
- old
+ new
@@ -181,10 +181,16 @@
@client.set("key3", "value3")
expect { @client.mget }.to raise_error(Redis::CommandError)
end
+ it 'raises an argument error when the data is a hash' do
+ @client.hincrby("key1", "cont1", 5)
+
+ expect { @client.mget("key1") }.to raise_error(Redis::CommandError)
+ end
+
it "should set multiple keys to multiple values" do
@client.mset(:key1, "value1", :key2, "value2")
expect(@client.get("key1")).to eq("value1")
expect(@client.get("key2")).to eq("value2")
@@ -238,9 +244,14 @@
it "should set the value and expiration of a key" do
@client.setex("key1", 30, "value1")
expect(@client.get("key1")).to eq("value1")
expect(@client.ttl("key1")).to eq(30)
+ end
+
+ it "should raise an error if a non-integer is provided as the expiration" do
+ expect { @client.setex("key1", 1.5, "value1") }.to raise_error(Redis::CommandError)
+ expect { @client.set("key1", "value1", ex: 1.5) }.to raise_error(Redis::CommandError)
end
it "should set the value of a key, only if the key does not exist" do
expect(@client.setnx("key1", "test value")).to eq(true)
expect(@client.setnx("key1", "new value")).to eq(false)