hydra/test/message_test.rb

32 lines
666 B
Ruby
Raw Normal View History

require 'test_helper'
2010-01-27 21:34:42 +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(
{:class=>MyMessage, :my_var=>"my value"},
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