$: << File.expand_path(File.dirname(__FILE__) + '/../lib')
require 'test/unit'
require 'xml_serialization'
class TestXMLSerialization < Test::Unit::TestCase
def test_rawxml_should_pass_thru
rawxml = RawXML.new 'content'
assert_equal rawxml, rawxml.to_xml
end
def test_fixnum
assert_equal '1', 1.to_xml
end
def test_string
assert_equal 'abc', 'abc'.to_xml
end
def test_symbol
assert_equal 'abc', :abc.to_xml
end
def test_array_of_strings
expected = <
a
b
c
EXPECTED
assert_equal expected, ['a', 'b', 'c'].to_xml
end
def test_array_of_fixnums_with_root_tag_specified
expected = <
1
2
3
EXPECTED
assert_equal expected, [1, 2, 3].to_xml(:root => 'numbers')
end
# this case is used by xslt_render to serialize the hash of controller instance variable values
def test_hash_with_array
expected = <
1
2
EXPECTED
assert_equal expected, {'numbers' => [1, 2]}.to_xml
assert_equal expected, {'numbers' => ['1', '2']}.to_xml
end
end