2 # -*- encoding: UTF-8 -*-
7 class TestToHTML < Test::Unit::TestCase
9 def test_String_to_html
10 assert 'hoge'.respond_to?(:to_html)
11 assert_equal 'hoge', 'hoge'.to_html
12 assert_equal "hoge\nfuga", "hoge\nfuga".to_html
15 def test_String_to_html_with_indentation
16 assert_equal ' hoge', 'hoge'.to_html(nil, 1)
17 assert_equal " hoge\n fuga", "hoge\nfuga".to_html(nil, 1)
21 assert nil.respond_to?(:to_html)
22 assert_equal '', nil.to_html
26 hash = {:hoge => 'hoge_value', :fuga => 'fuga_value'}
27 assert hash.respond_to?(:to_html)
30 assert_match /^<dl>/, html
31 assert(html.include?([
39 assert(html.include?([
47 assert_match /<\/dl>$/, html
50 def test_Array_to_html
51 array = ['hoge', 'fuga', 'piyo']
52 assert array.respond_to?(:to_html)
65 ].join("\n"), array.to_html)
69 attr_reader :fuga, :piyo
70 def initialize(fuga, piyo)
76 def test_Object_to_html
77 obj = TestClass.new('fuga_value', 'piyo_value')
78 assert obj.respond_to?(:to_html)
79 assert_equal obj.to_html, obj.to_s
82 {:fuga => @fuga, :piyo => @piyo}
85 assert_match /^<dl>/, html
86 assert(html.include?([
94 assert(html.include?([
102 assert_match /<\/dl>/, html
105 def test_compound_object_to_html
108 :nested_hash => {:hoge => 'hoge_value', :fuga => 'fuga_value'},
109 :nested_array => ['item1', 'item2']
112 assert_match /^<dl>/, html
113 assert(html.include?([
128 assert(html.include?([
136 assert(html.include?([
143 assert(html.include?([
151 assert(html.include?([
159 assert(html.include?([
163 assert_match /<\/dl>/, html