spec/strings_spec.rb in fakeredis-0.3.1 vs spec/strings_spec.rb in fakeredis-0.3.2
- old
+ new
@@ -33,32 +33,38 @@
end
it "should returns the bit value at offset in the string value stored at key" do
@client.set("key1", "a")
- @client.getbit("key1", 1).should == "1"
- @client.getbit("key1", 2).should == "1"
- @client.getbit("key1", 3).should == "0"
- @client.getbit("key1", 4).should == "0"
- @client.getbit("key1", 5).should == "0"
- @client.getbit("key1", 6).should == "0"
- @client.getbit("key1", 7).should == "1"
+ @client.getbit("key1", 1).should == 1
+ @client.getbit("key1", 2).should == 1
+ @client.getbit("key1", 3).should == 0
+ @client.getbit("key1", 4).should == 0
+ @client.getbit("key1", 5).should == 0
+ @client.getbit("key1", 6).should == 0
+ @client.getbit("key1", 7).should == 1
end
+ it "should allow direct bit manipulation even if the string isn't set" do
+ @client.setbit("key1", 10, 1)
+ @client.getbit("key1", 10).should == 1
+ end
+
it "should get a substring of the string stored at a key" do
@client.set("key1", "This a message")
@client.getrange("key1", 0, 3).should == "This"
+ @client.substr("key1", 0, 3).should == "This"
end
it "should set the string value of a key and return its old value" do
@client.set("key1","value1")
@client.getset("key1", "value2").should == "value1"
@client.get("key1").should == "value2"
end
-
+
it "should return nil for #getset if the key does not exist when setting" do
@client.getset("key1", "value1").should == nil
@client.get("key1").should == "value1"
end
@@ -66,15 +72,15 @@
@client.set("counter", "1")
@client.incr("counter").should == 2
@client.get("counter").should == "2"
end
-
+
it "should decrement the integer value of a key by one" do
@client.set("counter", "1")
@client.decr("counter").should == 0
-
+
@client.get("counter").should == "0"
end
it "should increment the integer value of a key by the given number" do
@client.set("counter", "10")
@@ -96,18 +102,13 @@
@client.set("key3", "value3")
@client.mget("key1", "key2", "key3").should == ["value1", "value2", "value3"]
end
- it "should get the values of all the given keys mapped" do
- @client.set("key1", "value1")
- @client.set("key2", "value2")
+ it 'raises an argument error when not passed any fields' do
@client.set("key3", "value3")
- response = @client.mapped_mget("key1", "key2", "key3")
- response["key1"].should == "value1"
- response["key2"].should == "value2"
- response["key3"].should == "value3"
+ lambda { @client.mget }.should raise_error(ArgumentError)
end
it "should set multiple keys to multiple values" do
@client.mset(:key1, "value1", :key2, "value2")