Permalink
Browse files

implementing the substr method

  • Loading branch information...
1 parent 96b035d commit c6a27eafc4e6f09273ca8f53f9df2678e9aecd11 David Pick committed Apr 19, 2012
Showing with 5 additions and 4 deletions.
  1. +1 −1 lib/redis/connection/memory.rb
  2. +4 −3 spec/strings_spec.rb
@@ -120,7 +120,6 @@ def read
# * subscribe
# * psubscribe
# * publish
- # * substr
# * zremrangebyrank
# * zunionstore
def flushdb
@@ -173,6 +172,7 @@ def getrange(key, start, ending)
return unless @data[key]
@data[key][start..ending]
end
+ alias :substr :getrange
def getset(key, value)
old_value = @data[key]
View
@@ -48,6 +48,7 @@ module FakeRedis
@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
@@ -56,7 +57,7 @@ module FakeRedis
@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"
@@ -68,11 +69,11 @@ module FakeRedis
@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

0 comments on commit c6a27ea

Please sign in to comment.