Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Filling out tests for HLEN, HKEYS, HVALS, hooking up processor for HG…

…ETALL
  • Loading branch information...
commit d6c4c89d0b231b6fab19ef6b567ebfbfaf03954b 1 parent ec8d11f
@qrush qrush authored
Showing with 31 additions and 0 deletions.
  1. +3 −0  lib/redis/client.rb
  2. +28 −0 spec/redis_spec.rb
View
3  lib/redis/client.rb
@@ -68,6 +68,9 @@ class Client
else
r.split(" ")
end
+ },
+ "hgetall" => lambda{|r|
+ Hash[*r]
}
}
View
28 spec/redis_spec.rb
@@ -721,4 +721,32 @@ def ==(other)
@r.hdel("rush", "YYZ").should be_true
@r.hexists("rush", "YYZ").should be_false
end
+
+ describe "with some hash values" do
+ before(:each) do
+ @r.hset("rush", "permanent waves", "1980")
+ @r.hset("rush", "moving pictures", "1981")
+ @r.hset("rush", "signals", "1982")
+ end
+
+ it "can get the length of the hash" do
+ @r.hlen("rush").should == 3
+ @r.hlen("yyz").should be_zero
+ end
+
+ it "can get the keys and values of the hash" do
+ @r.hkeys("rush").should == ["permanent waves", "moving pictures", "signals"]
+ @r.hvals("rush").should == %w[1980 1981 1982]
+ @r.hvals("yyz").should be_empty
+ end
+
+ it "returns a hash for HGETALL" do
+ @r.hgetall("rush").should == {
+ "permanent waves" => "1980",
+ "moving pictures" => "1981",
+ "signals" => "1982"
+ }
+ @r.hgetall("yyz").should == {}
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.