html-table 1.6.3 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/{CHANGES.rdoc → CHANGES.md} +76 -68
  4. data/Gemfile +2 -0
  5. data/MANIFEST.md +57 -0
  6. data/{README.rdoc → README.md} +80 -71
  7. data/Rakefile +122 -146
  8. data/doc/attributes.md +160 -0
  9. data/doc/table.md +173 -0
  10. data/doc/table_body.md +9 -0
  11. data/doc/table_caption.md +10 -0
  12. data/doc/table_colgroup.md +8 -0
  13. data/doc/table_colgroup_col.md +7 -0
  14. data/doc/table_content.md +17 -0
  15. data/doc/table_foot.md +8 -0
  16. data/doc/table_head.md +10 -0
  17. data/doc/table_row.md +114 -0
  18. data/doc/table_row_data.md +100 -0
  19. data/doc/table_row_header.md +6 -0
  20. data/examples/simple1.rb +7 -5
  21. data/html-table.gemspec +16 -11
  22. data/lib/html/body.rb +9 -7
  23. data/lib/html/caption.rb +4 -2
  24. data/lib/html/col.rb +37 -34
  25. data/lib/html/colgroup.rb +90 -97
  26. data/lib/html/content.rb +3 -6
  27. data/lib/html/data.rb +3 -1
  28. data/lib/html/foot.rb +53 -45
  29. data/lib/html/head.rb +54 -47
  30. data/lib/html/header.rb +5 -3
  31. data/lib/html/mixin/attribute_handler.rb +59 -55
  32. data/lib/html/mixin/html_handler.rb +33 -35
  33. data/lib/html/mixin/strongtyping.rb +6 -6
  34. data/lib/html/mixin/tag_handler.rb +6 -2
  35. data/lib/html/row.rb +156 -183
  36. data/lib/html/table.rb +45 -45
  37. data/lib/html/tablesection.rb +51 -46
  38. data/spec/attribute_handler_spec.rb +374 -0
  39. data/spec/body_spec.rb +98 -0
  40. data/spec/caption_spec.rb +83 -0
  41. data/spec/colgroup_col_spec.rb +34 -0
  42. data/spec/colgroup_spec.rb +97 -0
  43. data/spec/data_spec.rb +88 -0
  44. data/spec/foot_spec.rb +116 -0
  45. data/spec/head_spec.rb +116 -0
  46. data/spec/header_spec.rb +85 -0
  47. data/spec/html_handler_spec.rb +35 -0
  48. data/spec/row_spec.rb +163 -0
  49. data/spec/table_spec.rb +186 -0
  50. data/spec/tablesection_spec.rb +36 -0
  51. data/spec/tag_handler_spec.rb +85 -0
  52. data.tar.gz.sig +0 -0
  53. metadata +118 -92
  54. metadata.gz.sig +0 -0
  55. data/MANIFEST.rdoc +0 -56
  56. data/doc/attributes.rdoc +0 -143
  57. data/doc/table.rdoc +0 -156
  58. data/doc/table_body.rdoc +0 -9
  59. data/doc/table_caption.rdoc +0 -9
  60. data/doc/table_colgroup.rdoc +0 -8
  61. data/doc/table_colgroup_col.rdoc +0 -9
  62. data/doc/table_content.rdoc +0 -15
  63. data/doc/table_foot.rdoc +0 -8
  64. data/doc/table_head.rdoc +0 -11
  65. data/doc/table_row.rdoc +0 -105
  66. data/doc/table_row_data.rdoc +0 -92
  67. data/doc/table_row_header.rdoc +0 -7
  68. data/test/test_attribute_handler.rb +0 -361
  69. data/test/test_body.rb +0 -87
  70. data/test/test_caption.rb +0 -80
  71. data/test/test_col.rb +0 -40
  72. data/test/test_colgroup.rb +0 -89
  73. data/test/test_data.rb +0 -77
  74. data/test/test_foot.rb +0 -111
  75. data/test/test_head.rb +0 -104
  76. data/test/test_header.rb +0 -77
  77. data/test/test_html_handler.rb +0 -37
  78. data/test/test_row.rb +0 -141
  79. data/test/test_table.rb +0 -159
  80. data/test/test_tablesection.rb +0 -42
  81. data/test/test_tag_handler.rb +0 -90
data/test/test_caption.rb DELETED
@@ -1,80 +0,0 @@
1
- ################################################
2
- # test_caption.rb
3
- #
4
- # Test suite for the Table::Caption class
5
- ################################################
6
- require 'test-unit'
7
- require 'html/table'
8
- include HTML
9
-
10
- class TC_HTML_Table_Caption < Test::Unit::TestCase
11
- def setup
12
- @table = Table.new
13
- @tcaption = Table::Caption.new
14
- end
15
-
16
- def test_constructor
17
- assert_nothing_raised{ Table::Caption.new }
18
- assert_nothing_raised{ Table::Caption.new("foo") }
19
- assert_nothing_raised{ Table::Caption.new(1) }
20
- assert_nothing_raised{ Table::Caption.new(%w/foo bar baz/) }
21
- assert_nothing_raised{ Table::Caption.new([1,2,3]) }
22
- assert_nothing_raised{ Table::Caption.new([[1,2,3],["foo","bar"]]) }
23
- end
24
-
25
- def test_basic
26
- html = "<caption></caption>"
27
- assert_equal(html, @tcaption.html.gsub(/\s+/,''))
28
- end
29
-
30
- def test_with_attributes
31
- html = "<caption align='left' valign='top'></caption>"
32
- @tcaption.align = "left"
33
- @tcaption.valign = "top"
34
- assert_equal(html, @tcaption.html.gsub(/\s{2,}|\n+/,''))
35
- end
36
-
37
- def test_configure_not_allowed
38
- assert_raises(NoMethodError){ @tcaption.configure }
39
- end
40
-
41
- def test_add_content
42
- html = "<caption>hello world</caption>"
43
- @tcaption.content = "hello world"
44
- assert_equal(html,@tcaption.html.gsub(/\s{2,}/,''))
45
- end
46
-
47
- def test_add_multiple_content_items
48
- html = "<caption>hello world</caption>"
49
- @tcaption.content = "hello"," world"
50
- assert_equal(html,@tcaption.html.gsub(/\s{2,}/,''))
51
- end
52
-
53
- def test_add_content_in_constructor
54
- html = "<caption>hello world</caption>"
55
- @tcaption = Table::Caption.new("hello world")
56
- assert_equal(html, @tcaption.html.gsub(/\s{2,}/,''))
57
- end
58
-
59
- def test_indent_level
60
- assert_respond_to(Table::Caption,:indent_level)
61
- assert_respond_to(Table::Caption,:indent_level=)
62
- assert_raises(ArgumentTypeError){ Table::Caption.indent_level = "foo" }
63
- assert_nothing_raised{ Table::Caption.indent_level = 3 }
64
- end
65
-
66
- def test_only_row_zero_allowed
67
- assert_raises(ArgumentError){ @table[1] = @tcaption }
68
- end
69
-
70
- def test_automatically_set_to_row_zero
71
- @table.content = "hello","world"
72
- @table.push(@tcaption)
73
- assert_equal(true, @table[0].kind_of?(Table::Caption))
74
- end
75
-
76
- def teardown
77
- @table = nil
78
- @tcaption = nil
79
- end
80
- end
data/test/test_col.rb DELETED
@@ -1,40 +0,0 @@
1
- ##################################################
2
- # test_col.rb
3
- #
4
- # Test suite for the Table::ColGroup::Col class
5
- ##################################################
6
- require 'test-unit'
7
- require 'html/table'
8
- include HTML
9
-
10
- class TC_HTML_Table_Col < Test::Unit::TestCase
11
- def setup
12
- @col = Table::ColGroup::Col.new
13
- @cgroup = Table::ColGroup.new
14
- end
15
-
16
- def test_basic
17
- html = "<col>"
18
- assert_equal(html, @col.html.gsub(/\s{2,}|\n+/,''))
19
- end
20
-
21
- def test_no_configure
22
- assert_raises(NoMethodError){ @col.configure }
23
- end
24
-
25
- def test_no_content_allowed
26
- assert_raises(NoMethodError){ @col.content }
27
- assert_raises(NoMethodError){ @col.content = "foo" }
28
- end
29
-
30
- def test_indent_level
31
- assert_respond_to(Table::ColGroup::Col,:indent_level)
32
- assert_respond_to(Table::ColGroup::Col,:indent_level=)
33
- assert_raises(ArgumentTypeError){ Table::ColGroup::Col.indent_level = "foo" }
34
- assert_nothing_raised{ Table::ColGroup::Col.indent_level = 6 }
35
- end
36
-
37
- def teardown
38
- @col = nil
39
- end
40
- end
@@ -1,89 +0,0 @@
1
- ############################################
2
- # test_colgroup.rb
3
- #
4
- # Test suite for the Table::ColGroup class
5
- ############################################
6
- require 'test-unit'
7
- require 'html/table'
8
- include HTML
9
-
10
- class TC_HTML_Table_ColGroup < Test::Unit::TestCase
11
- def setup
12
- @cgroup = Table::ColGroup.new
13
- @col = Table::ColGroup::Col.new
14
- end
15
-
16
- def test_constructor
17
- assert_nothing_raised{ Table::ColGroup.new }
18
- assert_nothing_raised{ Table::ColGroup.new(@col) }
19
- assert_raises(TypeError){ Table::ColGroup.new("foo") }
20
- end
21
-
22
- def test_basic
23
- html = "<colgroup></colgroup>"
24
- assert_equal(html,@cgroup.html.gsub(/\s+/,''))
25
- end
26
-
27
- def test_with_attributes
28
- html = "<colgroup align='center' width='20%'></colgroup>"
29
- @cgroup.align = "center"
30
- @cgroup.width = "20%"
31
- assert_equal(html,@cgroup.html.gsub(/\s{2,}|\n+/,''))
32
- end
33
-
34
- def test_push_single_col_element
35
- html = "<colgroup><col></colgroup>"
36
- @cgroup.push(@col)
37
- assert_equal(html,@cgroup.html.gsub(/\s{2,}|\n+/,''))
38
- end
39
-
40
- def test_index_assignment_constraints
41
- assert_raises(ArgumentTypeError){ @cgroup[0] = "foo" }
42
- assert_raises(ArgumentTypeError){ @cgroup[0] = 1 }
43
- assert_raises(ArgumentTypeError){ @cgroup[1] = Table::Row.new }
44
- assert_nothing_raised{ @cgroup[0] = Table::ColGroup::Col.new }
45
- end
46
-
47
- def test_push_constraints
48
- assert_raises(TypeError){ @cgroup.push(7) }
49
- assert_raises(TypeError){ @cgroup.push("hello") }
50
- assert_raises(TypeError){ @cgroup.push(Table::Row.new) }
51
- assert_nothing_raised{ @cgroup.push(Table::ColGroup::Col.new) }
52
- end
53
-
54
- # Test '<<'
55
- def test_double_arrow_constraints
56
- assert_raises(TypeError){ @cgroup << 7 }
57
- assert_raises(TypeError){ @cgroup << "hello" }
58
- assert_raises(TypeError){ @cgroup << Table::Row.new }
59
- assert_nothing_raised{ @cgroup << Table::ColGroup::Col.new }
60
- end
61
-
62
- def test_configure_error
63
- assert_raises(ArgumentError){ @cgroup.configure(0,0){ } }
64
- end
65
-
66
- def test_content_error
67
- assert_raises(NoMethodError){ @cgroup.content }
68
- assert_raises(NoMethodError){ @cgroup.content = 'blah' }
69
- end
70
-
71
- def test_indent_level
72
- assert_respond_to(Table::ColGroup,:indent_level)
73
- assert_respond_to(Table::ColGroup,:indent_level=)
74
- assert_raises(ArgumentTypeError){ Table::ColGroup.indent_level = "foo" }
75
- assert_nothing_raised{ Table::ColGroup.indent_level = 6 }
76
- end
77
-
78
- def test_end_tags
79
- assert_respond_to(Table::ColGroup,:end_tags?)
80
- assert_respond_to(Table::ColGroup,:end_tags=)
81
- assert_raises(ArgumentTypeError){ Table::ColGroup.end_tags = "foo" }
82
- assert_raises(ArgumentTypeError){ Table::ColGroup.end_tags = 1 }
83
- assert_nothing_raised{ Table::ColGroup.end_tags = true }
84
- end
85
-
86
- def teardown
87
- @cgroup = nil
88
- end
89
- end
data/test/test_data.rb DELETED
@@ -1,77 +0,0 @@
1
- ##############################################
2
- # test_data.rb
3
- #
4
- # Test suite for the Table::Row::Data class
5
- ##############################################
6
- require 'test-unit'
7
- require 'html/table'
8
- include HTML
9
-
10
- class TC_HTML_Table_Row_Data < Test::Unit::TestCase
11
- def setup
12
- @tdata = Table::Row::Data.new
13
- end
14
-
15
- def test_constructor
16
- assert_nothing_raised{ Table::Row::Data.new }
17
- assert_nothing_raised{ Table::Row::Data.new("foo") }
18
- assert_nothing_raised{ Table::Row::Data.new(1) }
19
- assert_nothing_raised{ Table::Row::Data.new(%w/foo bar baz/) }
20
- assert_nothing_raised{ Table::Row::Data.new([1,2,3]) }
21
- assert_nothing_raised{ Table::Row::Data.new([[1,2,3],["foo","bar"]]) }
22
- end
23
-
24
- def test_basic
25
- html = "<td></td>"
26
- assert_equal(html,@tdata.html.gsub(/\s+/,''))
27
- end
28
-
29
- def test_with_attributes
30
- html = "<td align='left' width=3 nowrap></td>"
31
- @tdata.align = 'left'
32
- @tdata.width = 3
33
- @tdata.nowrap = true
34
- assert_equal(html,@tdata.html.gsub(/\s{2,}|\n+/,''))
35
- end
36
-
37
- def test_configure_not_allowed
38
- assert_raises(NoMethodError){ @tdata.configure }
39
- end
40
-
41
- def test_add_content
42
- html = "<td>hello world</td>"
43
- @tdata.content = "hello world"
44
- assert_equal(html,@tdata.html.gsub(/\s{2,}/,''))
45
- end
46
-
47
- def test_add_content_in_constructor
48
- html = "<td>hello world</td>"
49
- td = Table::Row::Data.new("hello world")
50
- assert_equal(html,td.html.gsub(/\s{2,}/,''))
51
- end
52
-
53
- def test_add_multiple_content_items
54
- html = "<td>hello world</td>"
55
- @tdata.content = "hello"," world"
56
- assert_equal(html,@tdata.html.gsub(/\s{2,}/,''))
57
- end
58
-
59
- def test_indent_level
60
- assert_respond_to(Table::Row::Data,:indent_level)
61
- assert_respond_to(Table::Row::Data,:indent_level=)
62
- assert_raises(ArgumentTypeError){ Table::Row::Data.indent_level = "foo" }
63
- assert_nothing_raised{ Table::Row::Data.indent_level = 6 }
64
- end
65
-
66
- def test_end_tags
67
- assert_respond_to(Table::Row::Data,:end_tags?)
68
- assert_respond_to(Table::Row::Data,:end_tags=)
69
- assert_raises(ArgumentTypeError){ Table::Row::Data.end_tags = "foo" }
70
- assert_raises(ArgumentTypeError){ Table::Row::Data.end_tags = 1 }
71
- assert_nothing_raised{ Table::Row::Data.end_tags = true }
72
- end
73
-
74
- def teardown
75
- @tdata = nil
76
- end
77
- end
data/test/test_foot.rb DELETED
@@ -1,111 +0,0 @@
1
- ###############################################################################
2
- # test_foot.rb
3
- #
4
- # Test suite for the Table::Foot class. The Table::Foot class is a singleton
5
- # class, so we have to take extra measures to ensure that a fresh instance
6
- # is created between tests.
7
- ###############################################################################
8
- require 'test-unit'
9
- require 'html/table'
10
- include HTML
11
-
12
- #####################################################################
13
- # Ensure that a fresh instance of Table::Foot is used between tests
14
- # by calling 'refresh' in the 'teardown' method.
15
- #####################################################################
16
- class Table::Foot
17
- private
18
- def refresh
19
- @@foot = nil
20
- end
21
- end
22
-
23
- class TC_HTML_Table_Foot < Test::Unit::TestCase
24
- def setup
25
- @table = Table.new
26
- @tfoot = Table::Foot.create
27
- end
28
-
29
- def test_new_not_allowed
30
- assert_raises(NoMethodError){ Table::Foot.new }
31
- end
32
-
33
- def test_constructor
34
- assert_nothing_raised{ Table::Foot.create }
35
- assert_nothing_raised{ Table::Foot.create("foo") }
36
- assert_nothing_raised{ Table::Foot.create(1) }
37
- assert_nothing_raised{ Table::Foot.create(%w/foo bar baz/) }
38
- assert_nothing_raised{ Table::Foot.create([1,2,3]) }
39
- assert_nothing_raised{ Table::Foot.create([[1,2,3], ["foo","bar"]]) }
40
- end
41
-
42
- def test_basic
43
- html = "<tfoot></tfoot>"
44
- assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n/,''))
45
- end
46
-
47
- def test_end_tags
48
- assert_respond_to(Table::Foot, :end_tags?)
49
- assert_respond_to(Table::Foot, :end_tags=)
50
- assert_nothing_raised{ Table::Foot.end_tags? }
51
- assert_nothing_raised{ Table::Foot.end_tags = true }
52
- end
53
-
54
- def test_end_tags_expected_errors
55
- assert_raises(StrongTyping::ArgumentTypeError){
56
- Table::Foot.end_tags = "foo"
57
- }
58
- end
59
-
60
- def test_with_attributes
61
- html = "<tfoot align='left' char='x'></tfoot>"
62
- @tfoot.align = "left"
63
- @tfoot.char = 'x'
64
- assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n/,''))
65
- end
66
-
67
- def test_push_single_row
68
- html = "<tfoot><tr><td>test</td></tr></tfoot>"
69
- @tfoot.push Table::Row.new{|r| r.content = "test"}
70
- assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n/,''))
71
- end
72
-
73
- def test_push_multiple_rows
74
- html = "<tfoot><tr><td>test</td></tr><tr><td>foo</td></tr></tfoot>"
75
- r1 = Table::Row.new{|r| r.content = "test"}
76
- r2 = Table::Row.new{|r| r.content = "foo"}
77
- @tfoot.push r1, r2
78
- assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n/,''))
79
- end
80
-
81
- def test_add_content_directly
82
- html = "<tfoot><tr><td>hello</td><td>world</td></tr></tfoot>"
83
- @tfoot.content = "hello","world"
84
- assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n+/,''))
85
- end
86
-
87
- def test_add_content_in_constructor
88
- html = "<tfoot><tr><td>hello</td><td>world</td></tr></tfoot>"
89
- @tfoot.send(:refresh)
90
- @tfoot = Table::Foot.create(["hello","world"])
91
- assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n+/,''))
92
- end
93
-
94
- def test_configure_column
95
- html = "<tfoot><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
96
- html += "</td></tr></tfoot>"
97
- @tfoot.content = "hello","world"
98
- @tfoot.configure(0,1){ |data|
99
- data.abbr = 'test'
100
- data.width = 3
101
- data.nowrap = true
102
- }
103
- assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n+/,''))
104
- end
105
-
106
- def teardown
107
- @table = nil
108
- @tfoot.send(:refresh)
109
- @tfoot = nil
110
- end
111
- end
data/test/test_head.rb DELETED
@@ -1,104 +0,0 @@
1
- ###############################################################################
2
- # test_head.rb
3
- #
4
- # Test suite for the Table::Head class. The Table::Head class is a singleton
5
- # class, so we have to take extra measures to ensure that a fresh instance
6
- # is created between tests.
7
- ###############################################################################
8
- require 'test-unit'
9
- require 'html/table'
10
- include HTML
11
-
12
- #####################################################################
13
- # Ensure that a fresh instance of Table::Head is used between tests
14
- # by calling 'refresh' in the 'teardown' method.
15
- #####################################################################
16
- class Table::Head
17
- private
18
- def refresh
19
- @@head = nil
20
- end
21
- end
22
-
23
- class TC_HTML_Table_Head < Test::Unit::TestCase
24
- def setup
25
- @table = Table.new
26
- @thead = Table::Head.create
27
- end
28
-
29
- def test_constructor
30
- assert_nothing_raised{ Table::Head.create }
31
- assert_nothing_raised{ Table::Head.create("foo") }
32
- assert_nothing_raised{ Table::Head.create(1) }
33
- assert_nothing_raised{ Table::Head.create(%w/foo bar baz/) }
34
- assert_nothing_raised{ Table::Head.create([1,2,3]) }
35
- assert_nothing_raised{ Table::Head.create([[1,2,3],["foo","bar"]]) }
36
- end
37
-
38
- def test_basic
39
- html = "<thead></thead>"
40
- assert_equal(html,@thead.html.gsub(/\s{2,}|\n/,''))
41
- end
42
-
43
- def test_end_tags
44
- assert_respond_to(Table::Head, :end_tags?)
45
- assert_respond_to(Table::Head, :end_tags=)
46
- assert_nothing_raised{ Table::Head.end_tags? }
47
- assert_nothing_raised{ Table::Head.end_tags = true }
48
- assert_raises(StrongTyping::ArgumentTypeError){
49
- Table::Head.end_tags = "foo"
50
- }
51
- end
52
-
53
- def test_with_attributes
54
- html = "<thead align='left' char='x'></thead>"
55
- @thead.align = "left"
56
- @thead.char = 'x'
57
- assert_equal(html,@thead.html.gsub(/\s{2,}|\n/,''))
58
- end
59
-
60
- def test_push_single_row
61
- html = "<thead><tr><td>test</td></tr></thead>"
62
- @thead.push Table::Row.new{|r| r.content = "test"}
63
- assert_equal(html,@thead.html.gsub(/\s{2,}|\n/,''))
64
- end
65
-
66
- def test_push_multiple_rows
67
- html = "<thead><tr><td>test</td></tr><tr><td>foo</td></tr></thead>"
68
- r1 = Table::Row.new("test")
69
- r2 = Table::Row.new("foo")
70
- @thead.push(r1, r2)
71
- assert_equal(html,@thead.html.gsub(/\s{2,}|\n/,''))
72
- end
73
-
74
- def test_add_content_directly
75
- html = "<thead><tr><td>hello</td><td>world</td></tr></thead>"
76
- @thead.content = "hello","world"
77
- assert_equal(html,@thead.html.gsub(/\s{2,}|\n+/,''))
78
- end
79
-
80
- def test_add_content_in_constructor
81
- html = "<thead><tr><td>hello</td><td>world</td></tr></thead>"
82
- @thead.send(:refresh)
83
- @thead = Table::Head.create(["hello","world"])
84
- assert_equal(html,@thead.html.gsub(/\s{2,}|\n+/,''))
85
- end
86
-
87
- def test_configure_column
88
- html = "<thead><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
89
- html += "</td></tr></thead>"
90
- @thead.content = "hello","world"
91
- @thead.configure(0,1){ |d|
92
- d.abbr = 'test'
93
- d.width = 3
94
- d.nowrap = true
95
- }
96
- assert_equal(html,@thead.html.gsub(/\s{2,}|\n+/,''))
97
- end
98
-
99
- def teardown
100
- @table = nil
101
- @thead.send(:refresh)
102
- @thead = nil
103
- end
104
- end
data/test/test_header.rb DELETED
@@ -1,77 +0,0 @@
1
- ################################################
2
- # test_header.rb
3
- #
4
- # Test suite for the Table::Row::Header class
5
- ################################################
6
- require 'test-unit'
7
- require 'html/table'
8
- include HTML
9
-
10
- class TC_HTML_Table_Row_Header < Test::Unit::TestCase
11
- def setup
12
- @theader = Table::Row::Header.new
13
- end
14
-
15
- def test_basic
16
- html = "<th></th>"
17
- assert_equal(html, @theader.html.gsub(/\s+/,''))
18
- end
19
-
20
- def test_constructor
21
- assert_nothing_raised{ Table::Row::Header.new }
22
- assert_nothing_raised{ Table::Row::Header.new("foo") }
23
- assert_nothing_raised{ Table::Row::Header.new(1) }
24
- assert_nothing_raised{ Table::Row::Header.new(%w/foo bar baz/) }
25
- assert_nothing_raised{ Table::Row::Header.new([1,2,3]) }
26
- assert_nothing_raised{ Table::Row::Header.new([[1,2,3],["foo","bar"]]) }
27
- end
28
-
29
- def test_with_attributes
30
- html = "<th align='left' colspan=3 nowrap></th>"
31
- @theader.align = 'left'
32
- @theader.colspan = 3
33
- @theader.nowrap = true
34
- assert_equal(html, @theader.html.gsub(/\s{2,}|\n+/,''))
35
- end
36
-
37
- def test_configure_not_allowed
38
- assert_raises(NoMethodError){ @theader.configure }
39
- end
40
-
41
- def test_add_content
42
- html = "<th>hello world</th>"
43
- @theader.content = "hello world"
44
- assert_equal(html, @theader.html.gsub(/\s{2,}/,''))
45
- end
46
-
47
- def test_add_multiple_content_items
48
- html = "<th>hello world</th>"
49
- @theader.content = "hello"," world"
50
- assert_equal(html, @theader.html.gsub(/\s{2,}/,''))
51
- end
52
-
53
- def test_add_content_in_constructor
54
- html = "<th>hello world</th>"
55
- @theader = Table::Row::Header.new("hello world")
56
- assert_equal(html, @theader.html.gsub(/\s{2,}/,''))
57
- end
58
-
59
- def test_indent_level
60
- assert_respond_to(Table::Row::Header,:indent_level)
61
- assert_respond_to(Table::Row::Header,:indent_level=)
62
- assert_raises(ArgumentTypeError){ Table::Row::Header.indent_level = "foo" }
63
- assert_nothing_raised{ Table::Row::Header.indent_level = 6 }
64
- end
65
-
66
- def test_end_tags
67
- assert_respond_to(Table::Row::Header,:end_tags?)
68
- assert_respond_to(Table::Row::Header,:end_tags=)
69
- assert_raises(ArgumentTypeError){ Table::Row::Header.end_tags = "foo" }
70
- assert_raises(ArgumentTypeError){ Table::Row::Header.end_tags = 1 }
71
- assert_nothing_raised{ Table::Row::Header.end_tags = true }
72
- end
73
-
74
- def teardown
75
- @theader = nil
76
- end
77
- end
@@ -1,37 +0,0 @@
1
- ############################################################################
2
- # test_html_handler.rb
3
- #
4
- # Test suite for the HtmlHandler module. For these tests, we'll use an
5
- # instance of the Table class where the module has been mixed in.
6
- ############################################################################
7
- require 'test-unit'
8
- require 'html/table'
9
- include HTML
10
-
11
- class TC_HtmlHandler < Test::Unit::TestCase
12
- def setup
13
- @table = Table.new(["foo",1,"bar"])
14
- end
15
-
16
- def test_html
17
- assert_respond_to(@table, :html)
18
- assert_nothing_raised{ @table.html }
19
- assert_raises(NoMethodError){ @table.html = "foo" }
20
- assert_kind_of(String, @table.html)
21
- assert_equal(true, @table.html.length > 0)
22
- end
23
-
24
- def test_modify_html
25
- assert_raises(ArgumentError){ @table.send(:modify_html) }
26
- assert_nothing_raised{ @table.send(:modify_html,"nowrap") }
27
- assert_nothing_raised{ @table.send(:modify_html,"align","top") }
28
- assert_nothing_raised{
29
- @table.send(:modify_html,"align","top")
30
- @table.send(:modify_html,"align","top")
31
- }
32
- end
33
-
34
- def teardown
35
- @table = nil
36
- end
37
- end