spec/sets_spec.rb in fakeredis-0.3.3 vs spec/sets_spec.rb in fakeredis-0.4.0
- old
+ new
@@ -5,27 +5,21 @@
before(:each) do
@client = Redis.new
end
it "should add a member to a set" do
- @client.sadd("key", "value").should be == true
- @client.sadd("key", "value").should be == false
+ @client.sadd("key", "value").should == true
+ @client.sadd("key", "value").should == false
- @client.smembers("key").should be == ["value"]
+ @client.smembers("key").should == ["value"]
end
- it "should not add multiple members to a set" do
- # redis.rb v2.2.2 just calls #to_s on the second argument
- @client.sadd("key", %w(value other something more)).should be_true
- @client.smembers("key").should be == [%w(value other something more).to_s]
- end
-
it "should get the number of members in a set" do
@client.sadd("key", "val1")
@client.sadd("key", "val2")
- @client.scard("key").should be == 2
+ @client.scard("key").should == 2
end
it "should subtract multiple sets" do
@client.sadd("key1", "a")
@client.sadd("key1", "b")
@@ -61,11 +55,11 @@
@client.sadd("key2", "c")
@client.sadd("key3", "a")
@client.sadd("key3", "c")
@client.sadd("key3", "e")
- @client.sinter("key1", "key2", "key3").should be == ["c"]
+ @client.sinter("key1", "key2", "key3").should == ["c"]
end
it "should intersect multiple sets and store the resulting set in a key" do
@client.sadd("key1", "a")
@client.sadd("key1", "b")
@@ -74,19 +68,19 @@
@client.sadd("key2", "c")
@client.sadd("key3", "a")
@client.sadd("key3", "c")
@client.sadd("key3", "e")
@client.sinterstore("key", "key1", "key2", "key3")
- @client.smembers("key").should be == ["c"]
+ @client.smembers("key").should == ["c"]
end
it "should determine if a given value is a member of a set" do
@client.sadd("key1", "a")
- @client.sismember("key1", "a").should be == true
- @client.sismember("key1", "b").should be == false
- @client.sismember("key2", "a").should be == false
+ @client.sismember("key1", "a").should == true
+ @client.sismember("key1", "b").should == false
+ @client.sismember("key2", "a").should == false
end
it "should get all the members in a set" do
@client.sadd("key", "a")
@client.sadd("key", "b")
@@ -98,14 +92,14 @@
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").should be == true
- @client.smove("key1", "key2", "a").should be == false
+ @client.smove("key1", "key2", "a").should == true
+ @client.smove("key1", "key2", "a").should == false
- @client.smembers("key1").should be == ["b"]
+ @client.smembers("key1").should == ["b"]
@client.smembers("key2").should =~ ["c", "a"]
end
it "should remove and return a random member from a set" do
@client.sadd("key1", "a")
@@ -124,22 +118,22 @@
end
it "should remove a member from a set" do
@client.sadd("key1", "a")
@client.sadd("key1", "b")
- @client.srem("key1", "a").should be == true
- @client.srem("key1", "a").should be == false
+ @client.srem("key1", "a").should == true
+ @client.srem("key1", "a").should == false
- @client.smembers("key1").should be == ["b"]
+ @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 be == false
+ @client.exists("key1").should == false
end
it "should add multiple sets" do
@client.sadd("key1", "a")
@client.sadd("key1", "b")