2011-08-23 11:01:48 +00:00
|
|
|
require 'test_helper'
|
2010-01-27 21:34:42 +00:00
|
|
|
|
2010-01-28 15:30:18 +00:00
|
|
|
class MessageTest < Test::Unit::TestCase
|
2010-01-27 21:34:42 +00:00
|
|
|
class MyMessage < Hydra::Message
|
|
|
|
attr_accessor :my_var
|
|
|
|
def serialize
|
|
|
|
super(:my_var => @my_var)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with a message" do
|
|
|
|
setup do
|
|
|
|
@m = MyMessage.new(:my_var => 'my value')
|
|
|
|
end
|
|
|
|
should "set values" do
|
|
|
|
assert_equal 'my value', @m.my_var
|
|
|
|
end
|
|
|
|
should "serialize" do
|
|
|
|
assert_equal(
|
2010-01-28 15:30:18 +00:00
|
|
|
{:class=>MyMessage, :my_var=>"my value"},
|
2010-01-27 22:19:32 +00:00
|
|
|
eval(@m.serialize)
|
2010-01-27 21:34:42 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
should "build from serialization" do
|
|
|
|
assert_equal(
|
|
|
|
@m.my_var,
|
|
|
|
Hydra::Message.build(eval(@m.serialize)).my_var
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|