Permalink
Browse files

Add a spec for RedisRpc::Packed

Should simply pack unpack ivars.
  • Loading branch information...
1 parent e0866c2 commit 2adf42c694f3c8811921b29418c0c5ea2b97cc6b @raykrueger committed Dec 17, 2011
Showing with 24 additions and 0 deletions.
  1. +24 −0 spec/redis_rpc_spec.rb
View
@@ -6,4 +6,28 @@
RedisRpc.logger.wont_equal nil
end
+ describe RedisRpc::Packed do
+
+ class TestObject
+ include RedisRpc::Packed
+
+ attr_accessor :first_name
+ attr_accessor :last_name
+ end
+
+ it "should pack all instance vars" do
+ o = TestObject.new
+ o.first_name = "Ray"
+ o.last_name = "Krueger"
+ packed = o.to_msgpack
+
+ packed.must_equal "\202\251last_name\247Krueger\252first_name\243Ray"
+
+ unpacked = MessagePack.unpack(packed)
+ unpacked["first_name"].must_equal o.first_name
+ unpacked["last_name"].must_equal o.last_name
+ end
+
+ end
+
end

0 comments on commit 2adf42c

Please sign in to comment.