Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a spec for RedisRpc::Packed

Should simply pack unpack ivars.
  • Loading branch information...
commit 2adf42c694f3c8811921b29418c0c5ea2b97cc6b 1 parent e0866c2
@raykrueger authored
Showing with 24 additions and 0 deletions.
  1. +24 −0 spec/redis_rpc_spec.rb
View
24 spec/redis_rpc_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.