html-table 1.3.3 → 1.3.4

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.
data/test/test_data.rb CHANGED
@@ -1,80 +1,80 @@
1
- ##############################################
2
- # test_data.rb
3
- #
4
- # Test suite for the Table::Row::Data class
5
- ##############################################
6
- require 'rubygems'
7
- gem 'test-unit'
8
-
9
- require 'test/unit'
10
- require 'html/table'
11
- include HTML
12
-
13
- class TC_HTML_Table_Row_Data < Test::Unit::TestCase
14
- def setup
15
- @tdata = Table::Row::Data.new
16
- end
17
-
18
- def test_constructor
19
- assert_nothing_raised{ Table::Row::Data.new }
20
- assert_nothing_raised{ Table::Row::Data.new("foo") }
21
- assert_nothing_raised{ Table::Row::Data.new(1) }
22
- assert_nothing_raised{ Table::Row::Data.new(%w/foo bar baz/) }
23
- assert_nothing_raised{ Table::Row::Data.new([1,2,3]) }
24
- assert_nothing_raised{ Table::Row::Data.new([[1,2,3],["foo","bar"]]) }
25
- end
26
-
27
- def test_basic
28
- html = "<td></td>"
29
- assert_equal(html,@tdata.html.gsub(/\s+/,''))
30
- end
31
-
32
- def test_with_attributes
33
- html = "<td align='left' width=3 nowrap></td>"
34
- @tdata.align = 'left'
35
- @tdata.width = 3
36
- @tdata.nowrap = true
37
- assert_equal(html,@tdata.html.gsub(/\s{2,}|\n+/,''))
38
- end
39
-
40
- def test_configure_not_allowed
41
- assert_raises(NoMethodError){ @tdata.configure }
42
- end
43
-
44
- def test_add_content
45
- html = "<td>hello world</td>"
46
- @tdata.content = "hello world"
47
- assert_equal(html,@tdata.html.gsub(/\s{2,}/,''))
48
- end
49
-
50
- def test_add_content_in_constructor
51
- html = "<td>hello world</td>"
52
- td = Table::Row::Data.new("hello world")
53
- assert_equal(html,td.html.gsub(/\s{2,}/,''))
54
- end
55
-
56
- def test_add_multiple_content_items
57
- html = "<td>hello world</td>"
58
- @tdata.content = "hello"," world"
59
- assert_equal(html,@tdata.html.gsub(/\s{2,}/,''))
60
- end
61
-
62
- def test_indent_level
63
- assert_respond_to(Table::Row::Data,:indent_level)
64
- assert_respond_to(Table::Row::Data,:indent_level=)
65
- assert_raises(ArgumentTypeError){ Table::Row::Data.indent_level = "foo" }
66
- assert_nothing_raised{ Table::Row::Data.indent_level = 6 }
67
- end
68
-
69
- def test_end_tags
70
- assert_respond_to(Table::Row::Data,:end_tags?)
71
- assert_respond_to(Table::Row::Data,:end_tags=)
72
- assert_raises(ArgumentTypeError){ Table::Row::Data.end_tags = "foo" }
73
- assert_raises(ArgumentTypeError){ Table::Row::Data.end_tags = 1 }
74
- assert_nothing_raised{ Table::Row::Data.end_tags = true }
75
- end
76
-
77
- def teardown
78
- @tdata = nil
79
- end
80
- end
1
+ ##############################################
2
+ # test_data.rb
3
+ #
4
+ # Test suite for the Table::Row::Data class
5
+ ##############################################
6
+ require 'rubygems'
7
+ gem 'test-unit'
8
+
9
+ require 'test/unit'
10
+ require 'html/table'
11
+ include HTML
12
+
13
+ class TC_HTML_Table_Row_Data < Test::Unit::TestCase
14
+ def setup
15
+ @tdata = Table::Row::Data.new
16
+ end
17
+
18
+ def test_constructor
19
+ assert_nothing_raised{ Table::Row::Data.new }
20
+ assert_nothing_raised{ Table::Row::Data.new("foo") }
21
+ assert_nothing_raised{ Table::Row::Data.new(1) }
22
+ assert_nothing_raised{ Table::Row::Data.new(%w/foo bar baz/) }
23
+ assert_nothing_raised{ Table::Row::Data.new([1,2,3]) }
24
+ assert_nothing_raised{ Table::Row::Data.new([[1,2,3],["foo","bar"]]) }
25
+ end
26
+
27
+ def test_basic
28
+ html = "<td></td>"
29
+ assert_equal(html,@tdata.html.gsub(/\s+/,''))
30
+ end
31
+
32
+ def test_with_attributes
33
+ html = "<td align='left' width=3 nowrap></td>"
34
+ @tdata.align = 'left'
35
+ @tdata.width = 3
36
+ @tdata.nowrap = true
37
+ assert_equal(html,@tdata.html.gsub(/\s{2,}|\n+/,''))
38
+ end
39
+
40
+ def test_configure_not_allowed
41
+ assert_raises(NoMethodError){ @tdata.configure }
42
+ end
43
+
44
+ def test_add_content
45
+ html = "<td>hello world</td>"
46
+ @tdata.content = "hello world"
47
+ assert_equal(html,@tdata.html.gsub(/\s{2,}/,''))
48
+ end
49
+
50
+ def test_add_content_in_constructor
51
+ html = "<td>hello world</td>"
52
+ td = Table::Row::Data.new("hello world")
53
+ assert_equal(html,td.html.gsub(/\s{2,}/,''))
54
+ end
55
+
56
+ def test_add_multiple_content_items
57
+ html = "<td>hello world</td>"
58
+ @tdata.content = "hello"," world"
59
+ assert_equal(html,@tdata.html.gsub(/\s{2,}/,''))
60
+ end
61
+
62
+ def test_indent_level
63
+ assert_respond_to(Table::Row::Data,:indent_level)
64
+ assert_respond_to(Table::Row::Data,:indent_level=)
65
+ assert_raises(ArgumentTypeError){ Table::Row::Data.indent_level = "foo" }
66
+ assert_nothing_raised{ Table::Row::Data.indent_level = 6 }
67
+ end
68
+
69
+ def test_end_tags
70
+ assert_respond_to(Table::Row::Data,:end_tags?)
71
+ assert_respond_to(Table::Row::Data,:end_tags=)
72
+ assert_raises(ArgumentTypeError){ Table::Row::Data.end_tags = "foo" }
73
+ assert_raises(ArgumentTypeError){ Table::Row::Data.end_tags = 1 }
74
+ assert_nothing_raised{ Table::Row::Data.end_tags = true }
75
+ end
76
+
77
+ def teardown
78
+ @tdata = nil
79
+ end
80
+ end
data/test/test_foot.rb CHANGED
@@ -1,114 +1,114 @@
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 'rubygems'
9
- gem 'test-unit'
10
-
11
- require 'test/unit'
12
- require 'html/table'
13
- include HTML
14
-
15
- #####################################################################
16
- # Ensure that a fresh instance of Table::Foot is used between tests
17
- # by calling 'refresh' in the 'teardown' method.
18
- #####################################################################
19
- class Table::Foot
20
- private
21
- def refresh
22
- @@foot = nil
23
- end
24
- end
25
-
26
- class TC_HTML_Table_Foot < Test::Unit::TestCase
27
- def setup
28
- @table = Table.new
29
- @tfoot = Table::Foot.create
30
- end
31
-
32
- def test_new_not_allowed
33
- assert_raises(NoMethodError){ Table::Foot.new }
34
- end
35
-
36
- def test_constructor
37
- assert_nothing_raised{ Table::Foot.create }
38
- assert_nothing_raised{ Table::Foot.create("foo") }
39
- assert_nothing_raised{ Table::Foot.create(1) }
40
- assert_nothing_raised{ Table::Foot.create(%w/foo bar baz/) }
41
- assert_nothing_raised{ Table::Foot.create([1,2,3]) }
42
- assert_nothing_raised{ Table::Foot.create([[1,2,3], ["foo","bar"]]) }
43
- end
44
-
45
- def test_basic
46
- html = "<tfoot></tfoot>"
47
- assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n/,''))
48
- end
49
-
50
- def test_end_tags
51
- assert_respond_to(Table::Foot, :end_tags?)
52
- assert_respond_to(Table::Foot, :end_tags=)
53
- assert_nothing_raised{ Table::Foot.end_tags? }
54
- assert_nothing_raised{ Table::Foot.end_tags = true }
55
- end
56
-
57
- def test_end_tags_expected_errors
58
- assert_raises(StrongTyping::ArgumentTypeError){
59
- Table::Foot.end_tags = "foo"
60
- }
61
- end
62
-
63
- def test_with_attributes
64
- html = "<tfoot align='left' char='x'></tfoot>"
65
- @tfoot.align = "left"
66
- @tfoot.char = 'x'
67
- assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n/,''))
68
- end
69
-
70
- def test_push_single_row
71
- html = "<tfoot><tr><td>test</td></tr></tfoot>"
72
- @tfoot.push Table::Row.new{|r| r.content = "test"}
73
- assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n/,''))
74
- end
75
-
76
- def test_push_multiple_rows
77
- html = "<tfoot><tr><td>test</td></tr><tr><td>foo</td></tr></tfoot>"
78
- r1 = Table::Row.new{|r| r.content = "test"}
79
- r2 = Table::Row.new{|r| r.content = "foo"}
80
- @tfoot.push r1, r2
81
- assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n/,''))
82
- end
83
-
84
- def test_add_content_directly
85
- html = "<tfoot><tr><td>hello</td><td>world</td></tr></tfoot>"
86
- @tfoot.content = "hello","world"
87
- assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n+/,''))
88
- end
89
-
90
- def test_add_content_in_constructor
91
- html = "<tfoot><tr><td>hello</td><td>world</td></tr></tfoot>"
92
- @tfoot.send(:refresh)
93
- @tfoot = Table::Foot.create(["hello","world"])
94
- assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n+/,''))
95
- end
96
-
97
- def test_configure_column
98
- html = "<tfoot><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
99
- html += "</td></tr></tfoot>"
100
- @tfoot.content = "hello","world"
101
- @tfoot.configure(0,1){ |data|
102
- data.abbr = 'test'
103
- data.width = 3
104
- data.nowrap = true
105
- }
106
- assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n+/,''))
107
- end
108
-
109
- def teardown
110
- @table = nil
111
- @tfoot.send(:refresh)
112
- @tfoot = nil
113
- end
114
- end
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 'rubygems'
9
+ gem 'test-unit'
10
+
11
+ require 'test/unit'
12
+ require 'html/table'
13
+ include HTML
14
+
15
+ #####################################################################
16
+ # Ensure that a fresh instance of Table::Foot is used between tests
17
+ # by calling 'refresh' in the 'teardown' method.
18
+ #####################################################################
19
+ class Table::Foot
20
+ private
21
+ def refresh
22
+ @@foot = nil
23
+ end
24
+ end
25
+
26
+ class TC_HTML_Table_Foot < Test::Unit::TestCase
27
+ def setup
28
+ @table = Table.new
29
+ @tfoot = Table::Foot.create
30
+ end
31
+
32
+ def test_new_not_allowed
33
+ assert_raises(NoMethodError){ Table::Foot.new }
34
+ end
35
+
36
+ def test_constructor
37
+ assert_nothing_raised{ Table::Foot.create }
38
+ assert_nothing_raised{ Table::Foot.create("foo") }
39
+ assert_nothing_raised{ Table::Foot.create(1) }
40
+ assert_nothing_raised{ Table::Foot.create(%w/foo bar baz/) }
41
+ assert_nothing_raised{ Table::Foot.create([1,2,3]) }
42
+ assert_nothing_raised{ Table::Foot.create([[1,2,3], ["foo","bar"]]) }
43
+ end
44
+
45
+ def test_basic
46
+ html = "<tfoot></tfoot>"
47
+ assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n/,''))
48
+ end
49
+
50
+ def test_end_tags
51
+ assert_respond_to(Table::Foot, :end_tags?)
52
+ assert_respond_to(Table::Foot, :end_tags=)
53
+ assert_nothing_raised{ Table::Foot.end_tags? }
54
+ assert_nothing_raised{ Table::Foot.end_tags = true }
55
+ end
56
+
57
+ def test_end_tags_expected_errors
58
+ assert_raises(StrongTyping::ArgumentTypeError){
59
+ Table::Foot.end_tags = "foo"
60
+ }
61
+ end
62
+
63
+ def test_with_attributes
64
+ html = "<tfoot align='left' char='x'></tfoot>"
65
+ @tfoot.align = "left"
66
+ @tfoot.char = 'x'
67
+ assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n/,''))
68
+ end
69
+
70
+ def test_push_single_row
71
+ html = "<tfoot><tr><td>test</td></tr></tfoot>"
72
+ @tfoot.push Table::Row.new{|r| r.content = "test"}
73
+ assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n/,''))
74
+ end
75
+
76
+ def test_push_multiple_rows
77
+ html = "<tfoot><tr><td>test</td></tr><tr><td>foo</td></tr></tfoot>"
78
+ r1 = Table::Row.new{|r| r.content = "test"}
79
+ r2 = Table::Row.new{|r| r.content = "foo"}
80
+ @tfoot.push r1, r2
81
+ assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n/,''))
82
+ end
83
+
84
+ def test_add_content_directly
85
+ html = "<tfoot><tr><td>hello</td><td>world</td></tr></tfoot>"
86
+ @tfoot.content = "hello","world"
87
+ assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n+/,''))
88
+ end
89
+
90
+ def test_add_content_in_constructor
91
+ html = "<tfoot><tr><td>hello</td><td>world</td></tr></tfoot>"
92
+ @tfoot.send(:refresh)
93
+ @tfoot = Table::Foot.create(["hello","world"])
94
+ assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n+/,''))
95
+ end
96
+
97
+ def test_configure_column
98
+ html = "<tfoot><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
99
+ html += "</td></tr></tfoot>"
100
+ @tfoot.content = "hello","world"
101
+ @tfoot.configure(0,1){ |data|
102
+ data.abbr = 'test'
103
+ data.width = 3
104
+ data.nowrap = true
105
+ }
106
+ assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n+/,''))
107
+ end
108
+
109
+ def teardown
110
+ @table = nil
111
+ @tfoot.send(:refresh)
112
+ @tfoot = nil
113
+ end
114
+ end
data/test/test_head.rb CHANGED
@@ -1,107 +1,107 @@
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 'rubygems'
9
- gem 'test-unit'
10
-
11
- require 'test/unit'
12
- require 'html/table'
13
- include HTML
14
-
15
- #####################################################################
16
- # Ensure that a fresh instance of Table::Head is used between tests
17
- # by calling 'refresh' in the 'teardown' method.
18
- #####################################################################
19
- class Table::Head
20
- private
21
- def refresh
22
- @@head = nil
23
- end
24
- end
25
-
26
- class TC_HTML_Table_Head < Test::Unit::TestCase
27
- def setup
28
- @table = Table.new
29
- @thead = Table::Head.create
30
- end
31
-
32
- def test_constructor
33
- assert_nothing_raised{ Table::Head.create }
34
- assert_nothing_raised{ Table::Head.create("foo") }
35
- assert_nothing_raised{ Table::Head.create(1) }
36
- assert_nothing_raised{ Table::Head.create(%w/foo bar baz/) }
37
- assert_nothing_raised{ Table::Head.create([1,2,3]) }
38
- assert_nothing_raised{ Table::Head.create([[1,2,3],["foo","bar"]]) }
39
- end
40
-
41
- def test_basic
42
- html = "<thead></thead>"
43
- assert_equal(html,@thead.html.gsub(/\s{2,}|\n/,''))
44
- end
45
-
46
- def test_end_tags
47
- assert_respond_to(Table::Head, :end_tags?)
48
- assert_respond_to(Table::Head, :end_tags=)
49
- assert_nothing_raised{ Table::Head.end_tags? }
50
- assert_nothing_raised{ Table::Head.end_tags = true }
51
- assert_raises(StrongTyping::ArgumentTypeError){
52
- Table::Head.end_tags = "foo"
53
- }
54
- end
55
-
56
- def test_with_attributes
57
- html = "<thead align='left' char='x'></thead>"
58
- @thead.align = "left"
59
- @thead.char = 'x'
60
- assert_equal(html,@thead.html.gsub(/\s{2,}|\n/,''))
61
- end
62
-
63
- def test_push_single_row
64
- html = "<thead><tr><td>test</td></tr></thead>"
65
- @thead.push Table::Row.new{|r| r.content = "test"}
66
- assert_equal(html,@thead.html.gsub(/\s{2,}|\n/,''))
67
- end
68
-
69
- def test_push_multiple_rows
70
- html = "<thead><tr><td>test</td></tr><tr><td>foo</td></tr></thead>"
71
- r1 = Table::Row.new("test")
72
- r2 = Table::Row.new("foo")
73
- @thead.push(r1, r2)
74
- assert_equal(html,@thead.html.gsub(/\s{2,}|\n/,''))
75
- end
76
-
77
- def test_add_content_directly
78
- html = "<thead><tr><td>hello</td><td>world</td></tr></thead>"
79
- @thead.content = "hello","world"
80
- assert_equal(html,@thead.html.gsub(/\s{2,}|\n+/,''))
81
- end
82
-
83
- def test_add_content_in_constructor
84
- html = "<thead><tr><td>hello</td><td>world</td></tr></thead>"
85
- @thead.send(:refresh)
86
- @thead = Table::Head.create(["hello","world"])
87
- assert_equal(html,@thead.html.gsub(/\s{2,}|\n+/,''))
88
- end
89
-
90
- def test_configure_column
91
- html = "<thead><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
92
- html += "</td></tr></thead>"
93
- @thead.content = "hello","world"
94
- @thead.configure(0,1){ |d|
95
- d.abbr = 'test'
96
- d.width = 3
97
- d.nowrap = true
98
- }
99
- assert_equal(html,@thead.html.gsub(/\s{2,}|\n+/,''))
100
- end
101
-
102
- def teardown
103
- @table = nil
104
- @thead.send(:refresh)
105
- @thead = nil
106
- end
107
- end
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 'rubygems'
9
+ gem 'test-unit'
10
+
11
+ require 'test/unit'
12
+ require 'html/table'
13
+ include HTML
14
+
15
+ #####################################################################
16
+ # Ensure that a fresh instance of Table::Head is used between tests
17
+ # by calling 'refresh' in the 'teardown' method.
18
+ #####################################################################
19
+ class Table::Head
20
+ private
21
+ def refresh
22
+ @@head = nil
23
+ end
24
+ end
25
+
26
+ class TC_HTML_Table_Head < Test::Unit::TestCase
27
+ def setup
28
+ @table = Table.new
29
+ @thead = Table::Head.create
30
+ end
31
+
32
+ def test_constructor
33
+ assert_nothing_raised{ Table::Head.create }
34
+ assert_nothing_raised{ Table::Head.create("foo") }
35
+ assert_nothing_raised{ Table::Head.create(1) }
36
+ assert_nothing_raised{ Table::Head.create(%w/foo bar baz/) }
37
+ assert_nothing_raised{ Table::Head.create([1,2,3]) }
38
+ assert_nothing_raised{ Table::Head.create([[1,2,3],["foo","bar"]]) }
39
+ end
40
+
41
+ def test_basic
42
+ html = "<thead></thead>"
43
+ assert_equal(html,@thead.html.gsub(/\s{2,}|\n/,''))
44
+ end
45
+
46
+ def test_end_tags
47
+ assert_respond_to(Table::Head, :end_tags?)
48
+ assert_respond_to(Table::Head, :end_tags=)
49
+ assert_nothing_raised{ Table::Head.end_tags? }
50
+ assert_nothing_raised{ Table::Head.end_tags = true }
51
+ assert_raises(StrongTyping::ArgumentTypeError){
52
+ Table::Head.end_tags = "foo"
53
+ }
54
+ end
55
+
56
+ def test_with_attributes
57
+ html = "<thead align='left' char='x'></thead>"
58
+ @thead.align = "left"
59
+ @thead.char = 'x'
60
+ assert_equal(html,@thead.html.gsub(/\s{2,}|\n/,''))
61
+ end
62
+
63
+ def test_push_single_row
64
+ html = "<thead><tr><td>test</td></tr></thead>"
65
+ @thead.push Table::Row.new{|r| r.content = "test"}
66
+ assert_equal(html,@thead.html.gsub(/\s{2,}|\n/,''))
67
+ end
68
+
69
+ def test_push_multiple_rows
70
+ html = "<thead><tr><td>test</td></tr><tr><td>foo</td></tr></thead>"
71
+ r1 = Table::Row.new("test")
72
+ r2 = Table::Row.new("foo")
73
+ @thead.push(r1, r2)
74
+ assert_equal(html,@thead.html.gsub(/\s{2,}|\n/,''))
75
+ end
76
+
77
+ def test_add_content_directly
78
+ html = "<thead><tr><td>hello</td><td>world</td></tr></thead>"
79
+ @thead.content = "hello","world"
80
+ assert_equal(html,@thead.html.gsub(/\s{2,}|\n+/,''))
81
+ end
82
+
83
+ def test_add_content_in_constructor
84
+ html = "<thead><tr><td>hello</td><td>world</td></tr></thead>"
85
+ @thead.send(:refresh)
86
+ @thead = Table::Head.create(["hello","world"])
87
+ assert_equal(html,@thead.html.gsub(/\s{2,}|\n+/,''))
88
+ end
89
+
90
+ def test_configure_column
91
+ html = "<thead><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
92
+ html += "</td></tr></thead>"
93
+ @thead.content = "hello","world"
94
+ @thead.configure(0,1){ |d|
95
+ d.abbr = 'test'
96
+ d.width = 3
97
+ d.nowrap = true
98
+ }
99
+ assert_equal(html,@thead.html.gsub(/\s{2,}|\n+/,''))
100
+ end
101
+
102
+ def teardown
103
+ @table = nil
104
+ @thead.send(:refresh)
105
+ @thead = nil
106
+ end
107
+ end