spec/sets_spec.rb in fakeredis-0.4.2 vs spec/sets_spec.rb in fakeredis-0.4.3
- old
+ new
@@ -11,10 +11,17 @@
@client.sadd("key", "value").should be == false
@client.smembers("key").should be == ["value"]
end
+ it "should raise error if command arguments count is not enough" do
+ expect { @client.sadd("key", []) }.to raise_error(Redis::CommandError, "ERR wrong number of arguments for 'sadd' command")
+ expect { @client.sinter(*[]) }.to raise_error(Redis::CommandError, "ERR wrong number of arguments for 'sinter' command")
+
+ @client.smembers("key").should be_empty
+ end
+
it "should add multiple members to a set" do
@client.sadd("key", %w(value other something more)).should be == 4
@client.sadd("key", %w(and additional values)).should be == 3
@client.smembers("key").should =~ ["value", "other", "something", "more", "and", "additional", "values"]
end
@@ -35,9 +42,16 @@
@client.sadd("key3", "a")
@client.sadd("key3", "c")
@client.sadd("key3", "e")
@client.sdiff("key1", "key2", "key3").should =~ ["b", "d"]
+ end
+
+ it "should subtract from a nonexistent set" do
+ @client.sadd("key2", "a")
+ @client.sadd("key2", "b")
+
+ @client.sdiff("key1", "key2").should == []
end
it "should subtract multiple sets and store the resulting set in a key" do
@client.sadd("key1", "a")
@client.sadd("key1", "b")