Permalink
Browse files

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

…ETALL
  • Loading branch information...
1 parent ec8d11f commit d6c4c89d0b231b6fab19ef6b567ebfbfaf03954b @qrush qrush committed Mar 23, 2010
Showing with 31 additions and 0 deletions.
  1. +3 −0 lib/redis/client.rb
  2. +28 −0 spec/redis_spec.rb
View
@@ -68,6 +68,9 @@ class Client
else
r.split(" ")
end
+ },
+ "hgetall" => lambda{|r|
+ Hash[*r]
}
}
View
@@ -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

0 comments on commit d6c4c89

Please sign in to comment.