spec/sets_spec.rb in fakeredis-0.2.2 vs spec/sets_spec.rb in fakeredis-0.3.0
- old
+ new
@@ -5,11 +5,12 @@
before(:each) do
@client = Redis.new
end
it "should add a member to a set" do
- @client.sadd("key", "value")
+ @client.sadd("key", "value").should == true
+ @client.sadd("key", "value").should == false
@client.smembers("key").should == ["value"]
end
it "should get the number of members in a set" do
@@ -91,11 +92,12 @@
it "should move a member from one set to another" do
@client.sadd("key1", "a")
@client.sadd("key1", "b")
@client.sadd("key2", "c")
- @client.smove("key1", "key2", "a")
+ @client.smove("key1", "key2", "a").should == true
+ @client.smove("key1", "key2", "a").should == false
@client.smembers("key1").should == ["b"]
@client.smembers("key2").should =~ ["c", "a"]
end
@@ -116,12 +118,22 @@
end
it "should remove a member from a set" do
@client.sadd("key1", "a")
@client.sadd("key1", "b")
- @client.srem("key1", "a")
+ @client.srem("key1", "a").should == true
+ @client.srem("key1", "a").should == false
@client.smembers("key1").should == ["b"]
+ end
+
+ it "should remove the set's key once it's empty" do
+ @client.sadd("key1", "a")
+ @client.sadd("key1", "b")
+ @client.srem("key1", "b")
+ @client.srem("key1", "a")
+
+ @client.exists("key1").should == false
end
it "should add multiple sets" do
@client.sadd("key1", "a")
@client.sadd("key1", "b")