html-table 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +3 -1
- data.tar.gz.sig +0 -0
- data/CHANGES +159 -155
- data/MANIFEST +59 -59
- data/README +132 -132
- data/certs/djberg96_pub.pem +22 -17
- data/doc/attributes.rdoc +143 -143
- data/doc/table.rdoc +158 -158
- data/doc/table_body.rdoc +9 -9
- data/doc/table_caption.rdoc +9 -9
- data/doc/table_colgroup.rdoc +8 -8
- data/doc/table_colgroup_col.rdoc +9 -9
- data/doc/table_content.rdoc +15 -15
- data/doc/table_foot.rdoc +8 -8
- data/doc/table_head.rdoc +11 -11
- data/doc/table_row.rdoc +105 -105
- data/doc/table_row_data.rdoc +92 -92
- data/doc/table_row_header.rdoc +7 -7
- data/examples/advanced.rb +128 -128
- data/examples/intermediate1.rb +72 -72
- data/examples/intermediate2.rb +62 -62
- data/examples/intermediate3.rb +46 -46
- data/examples/simple1.rb +39 -39
- data/examples/simple2.rb +47 -47
- data/examples/simple3.rb +41 -41
- data/html-table.gemspec +28 -28
- data/lib/html-table.rb +1 -1
- data/lib/html/attribute_handler.rb +403 -403
- data/lib/html/body.rb +37 -37
- data/lib/html/caption.rb +49 -49
- data/lib/html/col.rb +41 -41
- data/lib/html/colgroup.rb +113 -113
- data/lib/html/content.rb +18 -18
- data/lib/html/data.rb +69 -69
- data/lib/html/foot.rb +49 -49
- data/lib/html/head.rb +49 -49
- data/lib/html/header.rb +65 -65
- data/lib/html/html_handler.rb +120 -120
- data/lib/html/row.rb +188 -188
- data/lib/html/table.rb +323 -323
- data/lib/html/tablesection.rb +48 -48
- data/lib/html/tag_handler.rb +121 -121
- data/test/test_attribute_handler.rb +361 -361
- data/test/test_body.rb +87 -87
- data/test/test_caption.rb +80 -80
- data/test/test_col.rb +40 -40
- data/test/test_colgroup.rb +89 -89
- data/test/test_data.rb +77 -77
- data/test/test_foot.rb +111 -111
- data/test/test_head.rb +104 -104
- data/test/test_header.rb +77 -77
- data/test/test_html_handler.rb +37 -37
- data/test/test_row.rb +141 -141
- data/test/test_table.rb +159 -158
- data/test/test_tablesection.rb +42 -42
- data/test/test_tag_handler.rb +90 -90
- metadata +25 -20
- metadata.gz.sig +0 -0
data/test/test_body.rb
CHANGED
@@ -1,87 +1,87 @@
|
|
1
|
-
############################################
|
2
|
-
# test_body.rb
|
3
|
-
#
|
4
|
-
# Test suite for the Table::Body class
|
5
|
-
############################################
|
6
|
-
require 'test-unit'
|
7
|
-
require 'html/table'
|
8
|
-
include HTML
|
9
|
-
|
10
|
-
class TC_HTML_Table_Body < Test::Unit::TestCase
|
11
|
-
def setup
|
12
|
-
@table = Table.new
|
13
|
-
@tbody = Table::Body.new
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_constructor
|
17
|
-
assert_nothing_raised{ Table::Body.new }
|
18
|
-
assert_nothing_raised{ Table::Body.new("foo") }
|
19
|
-
assert_nothing_raised{ Table::Body.new(1) }
|
20
|
-
assert_nothing_raised{ Table::Body.new(%w/foo bar baz/) }
|
21
|
-
assert_nothing_raised{ Table::Body.new([1,2,3]) }
|
22
|
-
assert_nothing_raised{ Table::Body.new([[1,2,3],["foo","bar"]]) }
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_basic
|
26
|
-
html = "<tbody></tbody>"
|
27
|
-
assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_with_attributes
|
31
|
-
html = "<tbody align='left' char='x'></tbody>"
|
32
|
-
@tbody.align = "left"
|
33
|
-
@tbody.char = 'x'
|
34
|
-
assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_push_single_row
|
38
|
-
html = "<tbody><tr><td>test</td></tr></tbody>"
|
39
|
-
@tbody.push Table::Row.new{|r| r.content = "test" }
|
40
|
-
assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_push_multiple_rows
|
44
|
-
html = "<tbody><tr><td>test</td></tr><tr><td>foo</td></tr></tbody>"
|
45
|
-
r1 = Table::Row.new{|r| r.content = "test" }
|
46
|
-
r2 = Table::Row.new{|r| r.content = "foo" }
|
47
|
-
@tbody.push r1, r2
|
48
|
-
assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_add_content_directly
|
52
|
-
html = "<tbody><tr><td>hello</td><td>world</td></tr></tbody>"
|
53
|
-
@tbody.content = "hello","world"
|
54
|
-
assert_equal(html, @tbody.html.gsub(/\s{2,}|\n+/,''))
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_add_content_in_constructor
|
58
|
-
html = "<tbody><tr><td>hello</td><td>world</td></tr></tbody>"
|
59
|
-
tb = Table::Body.new(%w/hello world/)
|
60
|
-
assert_equal(html, tb.html.gsub(/\s{2,}|\n+/,''))
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_configure_column
|
64
|
-
html = "<tbody><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
|
65
|
-
html += "</td></tr></tbody>"
|
66
|
-
@tbody.content = "hello","world"
|
67
|
-
@tbody.configure(0,1){ |data|
|
68
|
-
data.abbr = 'test'
|
69
|
-
data.width = 3
|
70
|
-
data.nowrap = true
|
71
|
-
}
|
72
|
-
assert_equal(html, @tbody.html.gsub(/\s{2,}|\n+/,''))
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_end_tags
|
76
|
-
assert_respond_to(Table::Body, :end_tags?)
|
77
|
-
assert_respond_to(Table::Body, :end_tags=)
|
78
|
-
assert_raises(ArgumentTypeError){ Table::Body.end_tags = "foo" }
|
79
|
-
assert_raises(ArgumentTypeError){ Table::Body.end_tags = 1 }
|
80
|
-
assert_nothing_raised{ Table::Body.end_tags = true }
|
81
|
-
end
|
82
|
-
|
83
|
-
def teardown
|
84
|
-
@table = nil
|
85
|
-
@tbody = nil
|
86
|
-
end
|
87
|
-
end
|
1
|
+
############################################
|
2
|
+
# test_body.rb
|
3
|
+
#
|
4
|
+
# Test suite for the Table::Body class
|
5
|
+
############################################
|
6
|
+
require 'test-unit'
|
7
|
+
require 'html/table'
|
8
|
+
include HTML
|
9
|
+
|
10
|
+
class TC_HTML_Table_Body < Test::Unit::TestCase
|
11
|
+
def setup
|
12
|
+
@table = Table.new
|
13
|
+
@tbody = Table::Body.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_constructor
|
17
|
+
assert_nothing_raised{ Table::Body.new }
|
18
|
+
assert_nothing_raised{ Table::Body.new("foo") }
|
19
|
+
assert_nothing_raised{ Table::Body.new(1) }
|
20
|
+
assert_nothing_raised{ Table::Body.new(%w/foo bar baz/) }
|
21
|
+
assert_nothing_raised{ Table::Body.new([1,2,3]) }
|
22
|
+
assert_nothing_raised{ Table::Body.new([[1,2,3],["foo","bar"]]) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_basic
|
26
|
+
html = "<tbody></tbody>"
|
27
|
+
assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_with_attributes
|
31
|
+
html = "<tbody align='left' char='x'></tbody>"
|
32
|
+
@tbody.align = "left"
|
33
|
+
@tbody.char = 'x'
|
34
|
+
assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_push_single_row
|
38
|
+
html = "<tbody><tr><td>test</td></tr></tbody>"
|
39
|
+
@tbody.push Table::Row.new{|r| r.content = "test" }
|
40
|
+
assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_push_multiple_rows
|
44
|
+
html = "<tbody><tr><td>test</td></tr><tr><td>foo</td></tr></tbody>"
|
45
|
+
r1 = Table::Row.new{|r| r.content = "test" }
|
46
|
+
r2 = Table::Row.new{|r| r.content = "foo" }
|
47
|
+
@tbody.push r1, r2
|
48
|
+
assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_add_content_directly
|
52
|
+
html = "<tbody><tr><td>hello</td><td>world</td></tr></tbody>"
|
53
|
+
@tbody.content = "hello","world"
|
54
|
+
assert_equal(html, @tbody.html.gsub(/\s{2,}|\n+/,''))
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_add_content_in_constructor
|
58
|
+
html = "<tbody><tr><td>hello</td><td>world</td></tr></tbody>"
|
59
|
+
tb = Table::Body.new(%w/hello world/)
|
60
|
+
assert_equal(html, tb.html.gsub(/\s{2,}|\n+/,''))
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_configure_column
|
64
|
+
html = "<tbody><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
|
65
|
+
html += "</td></tr></tbody>"
|
66
|
+
@tbody.content = "hello","world"
|
67
|
+
@tbody.configure(0,1){ |data|
|
68
|
+
data.abbr = 'test'
|
69
|
+
data.width = 3
|
70
|
+
data.nowrap = true
|
71
|
+
}
|
72
|
+
assert_equal(html, @tbody.html.gsub(/\s{2,}|\n+/,''))
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_end_tags
|
76
|
+
assert_respond_to(Table::Body, :end_tags?)
|
77
|
+
assert_respond_to(Table::Body, :end_tags=)
|
78
|
+
assert_raises(ArgumentTypeError){ Table::Body.end_tags = "foo" }
|
79
|
+
assert_raises(ArgumentTypeError){ Table::Body.end_tags = 1 }
|
80
|
+
assert_nothing_raised{ Table::Body.end_tags = true }
|
81
|
+
end
|
82
|
+
|
83
|
+
def teardown
|
84
|
+
@table = nil
|
85
|
+
@tbody = nil
|
86
|
+
end
|
87
|
+
end
|
data/test/test_caption.rb
CHANGED
@@ -1,80 +1,80 @@
|
|
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
|
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
CHANGED
@@ -1,40 +1,40 @@
|
|
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
|
+
##################################################
|
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
|
data/test/test_colgroup.rb
CHANGED
@@ -1,89 +1,89 @@
|
|
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
|
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
|