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_body.rb CHANGED
@@ -1,90 +1,90 @@
1
- ############################################
2
- # test_body.rb
3
- #
4
- # Test suite for the Table::Body 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_Body < Test::Unit::TestCase
14
- def setup
15
- @table = Table.new
16
- @tbody = Table::Body.new
17
- end
18
-
19
- def test_constructor
20
- assert_nothing_raised{ Table::Body.new }
21
- assert_nothing_raised{ Table::Body.new("foo") }
22
- assert_nothing_raised{ Table::Body.new(1) }
23
- assert_nothing_raised{ Table::Body.new(%w/foo bar baz/) }
24
- assert_nothing_raised{ Table::Body.new([1,2,3]) }
25
- assert_nothing_raised{ Table::Body.new([[1,2,3],["foo","bar"]]) }
26
- end
27
-
28
- def test_basic
29
- html = "<tbody></tbody>"
30
- assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
31
- end
32
-
33
- def test_with_attributes
34
- html = "<tbody align='left' char='x'></tbody>"
35
- @tbody.align = "left"
36
- @tbody.char = 'x'
37
- assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
38
- end
39
-
40
- def test_push_single_row
41
- html = "<tbody><tr><td>test</td></tr></tbody>"
42
- @tbody.push Table::Row.new{|r| r.content = "test" }
43
- assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
44
- end
45
-
46
- def test_push_multiple_rows
47
- html = "<tbody><tr><td>test</td></tr><tr><td>foo</td></tr></tbody>"
48
- r1 = Table::Row.new{|r| r.content = "test" }
49
- r2 = Table::Row.new{|r| r.content = "foo" }
50
- @tbody.push r1, r2
51
- assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
52
- end
53
-
54
- def test_add_content_directly
55
- html = "<tbody><tr><td>hello</td><td>world</td></tr></tbody>"
56
- @tbody.content = "hello","world"
57
- assert_equal(html, @tbody.html.gsub(/\s{2,}|\n+/,''))
58
- end
59
-
60
- def test_add_content_in_constructor
61
- html = "<tbody><tr><td>hello</td><td>world</td></tr></tbody>"
62
- tb = Table::Body.new(%w/hello world/)
63
- assert_equal(html, tb.html.gsub(/\s{2,}|\n+/,''))
64
- end
65
-
66
- def test_configure_column
67
- html = "<tbody><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
68
- html += "</td></tr></tbody>"
69
- @tbody.content = "hello","world"
70
- @tbody.configure(0,1){ |data|
71
- data.abbr = 'test'
72
- data.width = 3
73
- data.nowrap = true
74
- }
75
- assert_equal(html, @tbody.html.gsub(/\s{2,}|\n+/,''))
76
- end
77
-
78
- def test_end_tags
79
- assert_respond_to(Table::Body, :end_tags?)
80
- assert_respond_to(Table::Body, :end_tags=)
81
- assert_raises(ArgumentTypeError){ Table::Body.end_tags = "foo" }
82
- assert_raises(ArgumentTypeError){ Table::Body.end_tags = 1 }
83
- assert_nothing_raised{ Table::Body.end_tags = true }
84
- end
85
-
86
- def teardown
87
- @table = nil
88
- @tbody = nil
89
- end
90
- end
1
+ ############################################
2
+ # test_body.rb
3
+ #
4
+ # Test suite for the Table::Body 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_Body < Test::Unit::TestCase
14
+ def setup
15
+ @table = Table.new
16
+ @tbody = Table::Body.new
17
+ end
18
+
19
+ def test_constructor
20
+ assert_nothing_raised{ Table::Body.new }
21
+ assert_nothing_raised{ Table::Body.new("foo") }
22
+ assert_nothing_raised{ Table::Body.new(1) }
23
+ assert_nothing_raised{ Table::Body.new(%w/foo bar baz/) }
24
+ assert_nothing_raised{ Table::Body.new([1,2,3]) }
25
+ assert_nothing_raised{ Table::Body.new([[1,2,3],["foo","bar"]]) }
26
+ end
27
+
28
+ def test_basic
29
+ html = "<tbody></tbody>"
30
+ assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
31
+ end
32
+
33
+ def test_with_attributes
34
+ html = "<tbody align='left' char='x'></tbody>"
35
+ @tbody.align = "left"
36
+ @tbody.char = 'x'
37
+ assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
38
+ end
39
+
40
+ def test_push_single_row
41
+ html = "<tbody><tr><td>test</td></tr></tbody>"
42
+ @tbody.push Table::Row.new{|r| r.content = "test" }
43
+ assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
44
+ end
45
+
46
+ def test_push_multiple_rows
47
+ html = "<tbody><tr><td>test</td></tr><tr><td>foo</td></tr></tbody>"
48
+ r1 = Table::Row.new{|r| r.content = "test" }
49
+ r2 = Table::Row.new{|r| r.content = "foo" }
50
+ @tbody.push r1, r2
51
+ assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
52
+ end
53
+
54
+ def test_add_content_directly
55
+ html = "<tbody><tr><td>hello</td><td>world</td></tr></tbody>"
56
+ @tbody.content = "hello","world"
57
+ assert_equal(html, @tbody.html.gsub(/\s{2,}|\n+/,''))
58
+ end
59
+
60
+ def test_add_content_in_constructor
61
+ html = "<tbody><tr><td>hello</td><td>world</td></tr></tbody>"
62
+ tb = Table::Body.new(%w/hello world/)
63
+ assert_equal(html, tb.html.gsub(/\s{2,}|\n+/,''))
64
+ end
65
+
66
+ def test_configure_column
67
+ html = "<tbody><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
68
+ html += "</td></tr></tbody>"
69
+ @tbody.content = "hello","world"
70
+ @tbody.configure(0,1){ |data|
71
+ data.abbr = 'test'
72
+ data.width = 3
73
+ data.nowrap = true
74
+ }
75
+ assert_equal(html, @tbody.html.gsub(/\s{2,}|\n+/,''))
76
+ end
77
+
78
+ def test_end_tags
79
+ assert_respond_to(Table::Body, :end_tags?)
80
+ assert_respond_to(Table::Body, :end_tags=)
81
+ assert_raises(ArgumentTypeError){ Table::Body.end_tags = "foo" }
82
+ assert_raises(ArgumentTypeError){ Table::Body.end_tags = 1 }
83
+ assert_nothing_raised{ Table::Body.end_tags = true }
84
+ end
85
+
86
+ def teardown
87
+ @table = nil
88
+ @tbody = nil
89
+ end
90
+ end
data/test/test_caption.rb CHANGED
@@ -1,83 +1,83 @@
1
- ################################################
2
- # test_caption.rb
3
- #
4
- # Test suite for the Table::Caption 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_Caption < Test::Unit::TestCase
14
- def setup
15
- @table = Table.new
16
- @tcaption = Table::Caption.new
17
- end
18
-
19
- def test_constructor
20
- assert_nothing_raised{ Table::Caption.new }
21
- assert_nothing_raised{ Table::Caption.new("foo") }
22
- assert_nothing_raised{ Table::Caption.new(1) }
23
- assert_nothing_raised{ Table::Caption.new(%w/foo bar baz/) }
24
- assert_nothing_raised{ Table::Caption.new([1,2,3]) }
25
- assert_nothing_raised{ Table::Caption.new([[1,2,3],["foo","bar"]]) }
26
- end
27
-
28
- def test_basic
29
- html = "<caption></caption>"
30
- assert_equal(html, @tcaption.html.gsub(/\s+/,''))
31
- end
32
-
33
- def test_with_attributes
34
- html = "<caption align='left' valign='top'></caption>"
35
- @tcaption.align = "left"
36
- @tcaption.valign = "top"
37
- assert_equal(html, @tcaption.html.gsub(/\s{2,}|\n+/,''))
38
- end
39
-
40
- def test_configure_not_allowed
41
- assert_raises(NoMethodError){ @tcaption.configure }
42
- end
43
-
44
- def test_add_content
45
- html = "<caption>hello world</caption>"
46
- @tcaption.content = "hello world"
47
- assert_equal(html,@tcaption.html.gsub(/\s{2,}/,''))
48
- end
49
-
50
- def test_add_multiple_content_items
51
- html = "<caption>hello world</caption>"
52
- @tcaption.content = "hello"," world"
53
- assert_equal(html,@tcaption.html.gsub(/\s{2,}/,''))
54
- end
55
-
56
- def test_add_content_in_constructor
57
- html = "<caption>hello world</caption>"
58
- @tcaption = Table::Caption.new("hello world")
59
- assert_equal(html, @tcaption.html.gsub(/\s{2,}/,''))
60
- end
61
-
62
- def test_indent_level
63
- assert_respond_to(Table::Caption,:indent_level)
64
- assert_respond_to(Table::Caption,:indent_level=)
65
- assert_raises(ArgumentTypeError){ Table::Caption.indent_level = "foo" }
66
- assert_nothing_raised{ Table::Caption.indent_level = 3 }
67
- end
68
-
69
- def test_only_row_zero_allowed
70
- assert_raises(ArgumentError){ @table[1] = @tcaption }
71
- end
72
-
73
- def test_automatically_set_to_row_zero
74
- @table.content = "hello","world"
75
- @table.push(@tcaption)
76
- assert_equal(true, @table[0].kind_of?(Table::Caption))
77
- end
78
-
79
- def teardown
80
- @table = nil
81
- @tcaption = nil
82
- end
83
- end
1
+ ################################################
2
+ # test_caption.rb
3
+ #
4
+ # Test suite for the Table::Caption 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_Caption < Test::Unit::TestCase
14
+ def setup
15
+ @table = Table.new
16
+ @tcaption = Table::Caption.new
17
+ end
18
+
19
+ def test_constructor
20
+ assert_nothing_raised{ Table::Caption.new }
21
+ assert_nothing_raised{ Table::Caption.new("foo") }
22
+ assert_nothing_raised{ Table::Caption.new(1) }
23
+ assert_nothing_raised{ Table::Caption.new(%w/foo bar baz/) }
24
+ assert_nothing_raised{ Table::Caption.new([1,2,3]) }
25
+ assert_nothing_raised{ Table::Caption.new([[1,2,3],["foo","bar"]]) }
26
+ end
27
+
28
+ def test_basic
29
+ html = "<caption></caption>"
30
+ assert_equal(html, @tcaption.html.gsub(/\s+/,''))
31
+ end
32
+
33
+ def test_with_attributes
34
+ html = "<caption align='left' valign='top'></caption>"
35
+ @tcaption.align = "left"
36
+ @tcaption.valign = "top"
37
+ assert_equal(html, @tcaption.html.gsub(/\s{2,}|\n+/,''))
38
+ end
39
+
40
+ def test_configure_not_allowed
41
+ assert_raises(NoMethodError){ @tcaption.configure }
42
+ end
43
+
44
+ def test_add_content
45
+ html = "<caption>hello world</caption>"
46
+ @tcaption.content = "hello world"
47
+ assert_equal(html,@tcaption.html.gsub(/\s{2,}/,''))
48
+ end
49
+
50
+ def test_add_multiple_content_items
51
+ html = "<caption>hello world</caption>"
52
+ @tcaption.content = "hello"," world"
53
+ assert_equal(html,@tcaption.html.gsub(/\s{2,}/,''))
54
+ end
55
+
56
+ def test_add_content_in_constructor
57
+ html = "<caption>hello world</caption>"
58
+ @tcaption = Table::Caption.new("hello world")
59
+ assert_equal(html, @tcaption.html.gsub(/\s{2,}/,''))
60
+ end
61
+
62
+ def test_indent_level
63
+ assert_respond_to(Table::Caption,:indent_level)
64
+ assert_respond_to(Table::Caption,:indent_level=)
65
+ assert_raises(ArgumentTypeError){ Table::Caption.indent_level = "foo" }
66
+ assert_nothing_raised{ Table::Caption.indent_level = 3 }
67
+ end
68
+
69
+ def test_only_row_zero_allowed
70
+ assert_raises(ArgumentError){ @table[1] = @tcaption }
71
+ end
72
+
73
+ def test_automatically_set_to_row_zero
74
+ @table.content = "hello","world"
75
+ @table.push(@tcaption)
76
+ assert_equal(true, @table[0].kind_of?(Table::Caption))
77
+ end
78
+
79
+ def teardown
80
+ @table = nil
81
+ @tcaption = nil
82
+ end
83
+ end
data/test/test_col.rb CHANGED
@@ -1,43 +1,43 @@
1
- ##################################################
2
- # test_col.rb
3
- #
4
- # Test suite for the Table::ColGroup::Col 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_Col < Test::Unit::TestCase
14
- def setup
15
- @col = Table::ColGroup::Col.new
16
- @cgroup = Table::ColGroup.new
17
- end
18
-
19
- def test_basic
20
- html = "<col>"
21
- assert_equal(html, @col.html.gsub(/\s{2,}|\n+/,''))
22
- end
23
-
24
- def test_no_configure
25
- assert_raises(NoMethodError){ @col.configure }
26
- end
27
-
28
- def test_no_content_allowed
29
- assert_raises(NoMethodError){ @col.content }
30
- assert_raises(NoMethodError){ @col.content = "foo" }
31
- end
32
-
33
- def test_indent_level
34
- assert_respond_to(Table::ColGroup::Col,:indent_level)
35
- assert_respond_to(Table::ColGroup::Col,:indent_level=)
36
- assert_raises(ArgumentTypeError){ Table::ColGroup::Col.indent_level = "foo" }
37
- assert_nothing_raised{ Table::ColGroup::Col.indent_level = 6 }
38
- end
39
-
40
- def teardown
41
- @col = nil
42
- end
43
- end
1
+ ##################################################
2
+ # test_col.rb
3
+ #
4
+ # Test suite for the Table::ColGroup::Col 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_Col < Test::Unit::TestCase
14
+ def setup
15
+ @col = Table::ColGroup::Col.new
16
+ @cgroup = Table::ColGroup.new
17
+ end
18
+
19
+ def test_basic
20
+ html = "<col>"
21
+ assert_equal(html, @col.html.gsub(/\s{2,}|\n+/,''))
22
+ end
23
+
24
+ def test_no_configure
25
+ assert_raises(NoMethodError){ @col.configure }
26
+ end
27
+
28
+ def test_no_content_allowed
29
+ assert_raises(NoMethodError){ @col.content }
30
+ assert_raises(NoMethodError){ @col.content = "foo" }
31
+ end
32
+
33
+ def test_indent_level
34
+ assert_respond_to(Table::ColGroup::Col,:indent_level)
35
+ assert_respond_to(Table::ColGroup::Col,:indent_level=)
36
+ assert_raises(ArgumentTypeError){ Table::ColGroup::Col.indent_level = "foo" }
37
+ assert_nothing_raised{ Table::ColGroup::Col.indent_level = 6 }
38
+ end
39
+
40
+ def teardown
41
+ @col = nil
42
+ end
43
+ end
@@ -1,92 +1,92 @@
1
- ############################################
2
- # test_colgroup.rb
3
- #
4
- # Test suite for the Table::ColGroup 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_ColGroup < Test::Unit::TestCase
14
- def setup
15
- @cgroup = Table::ColGroup.new
16
- @col = Table::ColGroup::Col.new
17
- end
18
-
19
- def test_constructor
20
- assert_nothing_raised{ Table::ColGroup.new }
21
- assert_nothing_raised{ Table::ColGroup.new(@col) }
22
- assert_raises(TypeError){ Table::ColGroup.new("foo") }
23
- end
24
-
25
- def test_basic
26
- html = "<colgroup></colgroup>"
27
- assert_equal(html,@cgroup.html.gsub(/\s+/,''))
28
- end
29
-
30
- def test_with_attributes
31
- html = "<colgroup align='center' width='20%'></colgroup>"
32
- @cgroup.align = "center"
33
- @cgroup.width = "20%"
34
- assert_equal(html,@cgroup.html.gsub(/\s{2,}|\n+/,''))
35
- end
36
-
37
- def test_push_single_col_element
38
- html = "<colgroup><col></colgroup>"
39
- @cgroup.push(@col)
40
- assert_equal(html,@cgroup.html.gsub(/\s{2,}|\n+/,''))
41
- end
42
-
43
- def test_index_assignment_constraints
44
- assert_raises(ArgumentTypeError){ @cgroup[0] = "foo" }
45
- assert_raises(ArgumentTypeError){ @cgroup[0] = 1 }
46
- assert_raises(ArgumentTypeError){ @cgroup[1] = Table::Row.new }
47
- assert_nothing_raised{ @cgroup[0] = Table::ColGroup::Col.new }
48
- end
49
-
50
- def test_push_constraints
51
- assert_raises(TypeError){ @cgroup.push(7) }
52
- assert_raises(TypeError){ @cgroup.push("hello") }
53
- assert_raises(TypeError){ @cgroup.push(Table::Row.new) }
54
- assert_nothing_raised{ @cgroup.push(Table::ColGroup::Col.new) }
55
- end
56
-
57
- # Test '<<'
58
- def test_double_arrow_constraints
59
- assert_raises(TypeError){ @cgroup << 7 }
60
- assert_raises(TypeError){ @cgroup << "hello" }
61
- assert_raises(TypeError){ @cgroup << Table::Row.new }
62
- assert_nothing_raised{ @cgroup << Table::ColGroup::Col.new }
63
- end
64
-
65
- def test_configure_error
66
- assert_raises(ArgumentError){ @cgroup.configure(0,0){ } }
67
- end
68
-
69
- def test_content_error
70
- assert_raises(NoMethodError){ @cgroup.content }
71
- assert_raises(NoMethodError){ @cgroup.content = 'blah' }
72
- end
73
-
74
- def test_indent_level
75
- assert_respond_to(Table::ColGroup,:indent_level)
76
- assert_respond_to(Table::ColGroup,:indent_level=)
77
- assert_raises(ArgumentTypeError){ Table::ColGroup.indent_level = "foo" }
78
- assert_nothing_raised{ Table::ColGroup.indent_level = 6 }
79
- end
80
-
81
- def test_end_tags
82
- assert_respond_to(Table::ColGroup,:end_tags?)
83
- assert_respond_to(Table::ColGroup,:end_tags=)
84
- assert_raises(ArgumentTypeError){ Table::ColGroup.end_tags = "foo" }
85
- assert_raises(ArgumentTypeError){ Table::ColGroup.end_tags = 1 }
86
- assert_nothing_raised{ Table::ColGroup.end_tags = true }
87
- end
88
-
89
- def teardown
90
- @cgroup = nil
91
- end
92
- end
1
+ ############################################
2
+ # test_colgroup.rb
3
+ #
4
+ # Test suite for the Table::ColGroup 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_ColGroup < Test::Unit::TestCase
14
+ def setup
15
+ @cgroup = Table::ColGroup.new
16
+ @col = Table::ColGroup::Col.new
17
+ end
18
+
19
+ def test_constructor
20
+ assert_nothing_raised{ Table::ColGroup.new }
21
+ assert_nothing_raised{ Table::ColGroup.new(@col) }
22
+ assert_raises(TypeError){ Table::ColGroup.new("foo") }
23
+ end
24
+
25
+ def test_basic
26
+ html = "<colgroup></colgroup>"
27
+ assert_equal(html,@cgroup.html.gsub(/\s+/,''))
28
+ end
29
+
30
+ def test_with_attributes
31
+ html = "<colgroup align='center' width='20%'></colgroup>"
32
+ @cgroup.align = "center"
33
+ @cgroup.width = "20%"
34
+ assert_equal(html,@cgroup.html.gsub(/\s{2,}|\n+/,''))
35
+ end
36
+
37
+ def test_push_single_col_element
38
+ html = "<colgroup><col></colgroup>"
39
+ @cgroup.push(@col)
40
+ assert_equal(html,@cgroup.html.gsub(/\s{2,}|\n+/,''))
41
+ end
42
+
43
+ def test_index_assignment_constraints
44
+ assert_raises(ArgumentTypeError){ @cgroup[0] = "foo" }
45
+ assert_raises(ArgumentTypeError){ @cgroup[0] = 1 }
46
+ assert_raises(ArgumentTypeError){ @cgroup[1] = Table::Row.new }
47
+ assert_nothing_raised{ @cgroup[0] = Table::ColGroup::Col.new }
48
+ end
49
+
50
+ def test_push_constraints
51
+ assert_raises(TypeError){ @cgroup.push(7) }
52
+ assert_raises(TypeError){ @cgroup.push("hello") }
53
+ assert_raises(TypeError){ @cgroup.push(Table::Row.new) }
54
+ assert_nothing_raised{ @cgroup.push(Table::ColGroup::Col.new) }
55
+ end
56
+
57
+ # Test '<<'
58
+ def test_double_arrow_constraints
59
+ assert_raises(TypeError){ @cgroup << 7 }
60
+ assert_raises(TypeError){ @cgroup << "hello" }
61
+ assert_raises(TypeError){ @cgroup << Table::Row.new }
62
+ assert_nothing_raised{ @cgroup << Table::ColGroup::Col.new }
63
+ end
64
+
65
+ def test_configure_error
66
+ assert_raises(ArgumentError){ @cgroup.configure(0,0){ } }
67
+ end
68
+
69
+ def test_content_error
70
+ assert_raises(NoMethodError){ @cgroup.content }
71
+ assert_raises(NoMethodError){ @cgroup.content = 'blah' }
72
+ end
73
+
74
+ def test_indent_level
75
+ assert_respond_to(Table::ColGroup,:indent_level)
76
+ assert_respond_to(Table::ColGroup,:indent_level=)
77
+ assert_raises(ArgumentTypeError){ Table::ColGroup.indent_level = "foo" }
78
+ assert_nothing_raised{ Table::ColGroup.indent_level = 6 }
79
+ end
80
+
81
+ def test_end_tags
82
+ assert_respond_to(Table::ColGroup,:end_tags?)
83
+ assert_respond_to(Table::ColGroup,:end_tags=)
84
+ assert_raises(ArgumentTypeError){ Table::ColGroup.end_tags = "foo" }
85
+ assert_raises(ArgumentTypeError){ Table::ColGroup.end_tags = 1 }
86
+ assert_nothing_raised{ Table::ColGroup.end_tags = true }
87
+ end
88
+
89
+ def teardown
90
+ @cgroup = nil
91
+ end
92
+ end