html-table 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +13 -0
- data/MANIFEST +13 -13
- data/README +27 -26
- data/Rakefile +120 -2
- data/examples/advanced.rb +128 -0
- data/examples/intermediate1.rb +72 -0
- data/examples/intermediate2.rb +62 -0
- data/examples/intermediate3.rb +46 -0
- data/examples/simple1.rb +39 -0
- data/examples/simple2.rb +47 -0
- data/examples/simple3.rb +41 -0
- data/html-table.gemspec +5 -3
- data/lib/html/attribute_handler.rb +8 -16
- data/lib/html/table.rb +11 -4
- data/lib/html/tag_handler.rb +1 -3
- data/test/{tc_attribute_handler.rb → test_attribute_handler.rb} +110 -9
- data/test/{tc_body.rb → test_body.rb} +31 -28
- data/test/{tc_caption.rb → test_caption.rb} +26 -23
- data/test/{tc_col.rb → test_col.rb} +13 -10
- data/test/{tc_colgroup.rb → test_colgroup.rb} +29 -26
- data/test/{tc_data.rb → test_data.rb} +18 -15
- data/test/{tc_foot.rb → test_foot.rb} +34 -28
- data/test/{tc_head.rb → test_head.rb} +27 -24
- data/test/{tc_header.rb → test_header.rb} +20 -17
- data/test/test_html_handler.rb +40 -0
- data/test/test_row.rb +144 -0
- data/test/{tc_table.rb → test_table.rb} +47 -44
- data/test/{tc_tablesection.rb → test_tablesection.rb} +14 -11
- data/test/test_tag_handler.rb +93 -0
- metadata +61 -37
- data/html-table-1.3.2.gem +0 -0
- data/test/tc_html_handler.rb +0 -37
- data/test/tc_row.rb +0 -141
- data/test/tc_tag_handler.rb +0 -82
@@ -1,16 +1,19 @@
|
|
1
1
|
############################################
|
2
|
-
#
|
2
|
+
# test_body.rb
|
3
3
|
#
|
4
4
|
# Test suite for the Table::Body class
|
5
5
|
############################################
|
6
|
-
require
|
7
|
-
|
6
|
+
require 'rubygems'
|
7
|
+
gem 'test-unit'
|
8
|
+
|
9
|
+
require 'test/unit'
|
10
|
+
require 'html/table'
|
8
11
|
include HTML
|
9
12
|
|
10
13
|
class TC_HTML_Table_Body < Test::Unit::TestCase
|
11
14
|
def setup
|
12
|
-
@
|
13
|
-
@
|
15
|
+
@table = Table.new
|
16
|
+
@tbody = Table::Body.new
|
14
17
|
end
|
15
18
|
|
16
19
|
def test_constructor
|
@@ -24,64 +27,64 @@ class TC_HTML_Table_Body < Test::Unit::TestCase
|
|
24
27
|
|
25
28
|
def test_basic
|
26
29
|
html = "<tbody></tbody>"
|
27
|
-
assert_equal(html
|
30
|
+
assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
|
28
31
|
end
|
29
32
|
|
30
33
|
def test_with_attributes
|
31
34
|
html = "<tbody align='left' char='x'></tbody>"
|
32
|
-
@
|
33
|
-
@
|
34
|
-
assert_equal(html
|
35
|
+
@tbody.align = "left"
|
36
|
+
@tbody.char = 'x'
|
37
|
+
assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
|
35
38
|
end
|
36
39
|
|
37
40
|
def test_push_single_row
|
38
41
|
html = "<tbody><tr><td>test</td></tr></tbody>"
|
39
|
-
@
|
40
|
-
assert_equal(html
|
42
|
+
@tbody.push Table::Row.new{|r| r.content = "test" }
|
43
|
+
assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
|
41
44
|
end
|
42
45
|
|
43
46
|
def test_push_multiple_rows
|
44
47
|
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
|
-
@
|
48
|
-
assert_equal(html
|
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/,''))
|
49
52
|
end
|
50
53
|
|
51
54
|
def test_add_content_directly
|
52
55
|
html = "<tbody><tr><td>hello</td><td>world</td></tr></tbody>"
|
53
|
-
@
|
54
|
-
assert_equal(html
|
56
|
+
@tbody.content = "hello","world"
|
57
|
+
assert_equal(html, @tbody.html.gsub(/\s{2,}|\n+/,''))
|
55
58
|
end
|
56
59
|
|
57
60
|
def test_add_content_in_constructor
|
58
61
|
html = "<tbody><tr><td>hello</td><td>world</td></tr></tbody>"
|
59
62
|
tb = Table::Body.new(%w/hello world/)
|
60
|
-
assert_equal(html,tb.html.gsub(/\s{2,}|\n+/,''))
|
63
|
+
assert_equal(html, tb.html.gsub(/\s{2,}|\n+/,''))
|
61
64
|
end
|
62
65
|
|
63
66
|
def test_configure_column
|
64
67
|
html = "<tbody><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
|
65
68
|
html += "</td></tr></tbody>"
|
66
|
-
@
|
67
|
-
@
|
68
|
-
|
69
|
-
|
70
|
-
|
69
|
+
@tbody.content = "hello","world"
|
70
|
+
@tbody.configure(0,1){ |data|
|
71
|
+
data.abbr = 'test'
|
72
|
+
data.width = 3
|
73
|
+
data.nowrap = true
|
71
74
|
}
|
72
|
-
assert_equal(html
|
75
|
+
assert_equal(html, @tbody.html.gsub(/\s{2,}|\n+/,''))
|
73
76
|
end
|
74
77
|
|
75
78
|
def test_end_tags
|
76
|
-
assert_respond_to(Table::Body
|
77
|
-
assert_respond_to(Table::Body
|
79
|
+
assert_respond_to(Table::Body, :end_tags?)
|
80
|
+
assert_respond_to(Table::Body, :end_tags=)
|
78
81
|
assert_raises(ArgumentTypeError){ Table::Body.end_tags = "foo" }
|
79
82
|
assert_raises(ArgumentTypeError){ Table::Body.end_tags = 1 }
|
80
83
|
assert_nothing_raised{ Table::Body.end_tags = true }
|
81
84
|
end
|
82
85
|
|
83
86
|
def teardown
|
84
|
-
@
|
85
|
-
@
|
87
|
+
@table = nil
|
88
|
+
@tbody = nil
|
86
89
|
end
|
87
90
|
end
|
@@ -1,16 +1,19 @@
|
|
1
1
|
################################################
|
2
|
-
#
|
2
|
+
# test_caption.rb
|
3
3
|
#
|
4
4
|
# Test suite for the Table::Caption class
|
5
5
|
################################################
|
6
|
-
require
|
7
|
-
|
6
|
+
require 'rubygems'
|
7
|
+
gem 'test-unit'
|
8
|
+
|
9
|
+
require 'test/unit'
|
10
|
+
require 'html/table'
|
8
11
|
include HTML
|
9
12
|
|
10
13
|
class TC_HTML_Table_Caption < Test::Unit::TestCase
|
11
14
|
def setup
|
12
|
-
@
|
13
|
-
@
|
15
|
+
@table = Table.new
|
16
|
+
@tcaption = Table::Caption.new
|
14
17
|
end
|
15
18
|
|
16
19
|
def test_constructor
|
@@ -24,36 +27,36 @@ class TC_HTML_Table_Caption < Test::Unit::TestCase
|
|
24
27
|
|
25
28
|
def test_basic
|
26
29
|
html = "<caption></caption>"
|
27
|
-
assert_equal(html
|
30
|
+
assert_equal(html, @tcaption.html.gsub(/\s+/,''))
|
28
31
|
end
|
29
32
|
|
30
33
|
def test_with_attributes
|
31
34
|
html = "<caption align='left' valign='top'></caption>"
|
32
|
-
@
|
33
|
-
@
|
34
|
-
assert_equal(html
|
35
|
+
@tcaption.align = "left"
|
36
|
+
@tcaption.valign = "top"
|
37
|
+
assert_equal(html, @tcaption.html.gsub(/\s{2,}|\n+/,''))
|
35
38
|
end
|
36
39
|
|
37
40
|
def test_configure_not_allowed
|
38
|
-
assert_raises(NoMethodError){ @
|
41
|
+
assert_raises(NoMethodError){ @tcaption.configure }
|
39
42
|
end
|
40
43
|
|
41
44
|
def test_add_content
|
42
45
|
html = "<caption>hello world</caption>"
|
43
|
-
@
|
44
|
-
assert_equal(html,@
|
46
|
+
@tcaption.content = "hello world"
|
47
|
+
assert_equal(html,@tcaption.html.gsub(/\s{2,}/,''))
|
45
48
|
end
|
46
49
|
|
47
50
|
def test_add_multiple_content_items
|
48
51
|
html = "<caption>hello world</caption>"
|
49
|
-
@
|
50
|
-
assert_equal(html,@
|
52
|
+
@tcaption.content = "hello"," world"
|
53
|
+
assert_equal(html,@tcaption.html.gsub(/\s{2,}/,''))
|
51
54
|
end
|
52
55
|
|
53
56
|
def test_add_content_in_constructor
|
54
57
|
html = "<caption>hello world</caption>"
|
55
|
-
|
56
|
-
assert_equal(html,
|
58
|
+
@tcaption = Table::Caption.new("hello world")
|
59
|
+
assert_equal(html, @tcaption.html.gsub(/\s{2,}/,''))
|
57
60
|
end
|
58
61
|
|
59
62
|
def test_indent_level
|
@@ -63,18 +66,18 @@ class TC_HTML_Table_Caption < Test::Unit::TestCase
|
|
63
66
|
assert_nothing_raised{ Table::Caption.indent_level = 3 }
|
64
67
|
end
|
65
68
|
|
66
|
-
def
|
67
|
-
assert_raises(ArgumentError){ @
|
69
|
+
def test_only_row_zero_allowed
|
70
|
+
assert_raises(ArgumentError){ @table[1] = @tcaption }
|
68
71
|
end
|
69
72
|
|
70
73
|
def test_automatically_set_to_row_zero
|
71
|
-
@
|
72
|
-
@
|
73
|
-
assert_equal(true
|
74
|
+
@table.content = "hello","world"
|
75
|
+
@table.push(@tcaption)
|
76
|
+
assert_equal(true, @table[0].kind_of?(Table::Caption))
|
74
77
|
end
|
75
78
|
|
76
79
|
def teardown
|
77
|
-
@
|
78
|
-
@
|
80
|
+
@table = nil
|
81
|
+
@tcaption = nil
|
79
82
|
end
|
80
83
|
end
|
@@ -1,30 +1,33 @@
|
|
1
1
|
##################################################
|
2
|
-
#
|
2
|
+
# test_col.rb
|
3
3
|
#
|
4
4
|
# Test suite for the Table::ColGroup::Col class
|
5
5
|
##################################################
|
6
|
-
require
|
7
|
-
|
6
|
+
require 'rubygems'
|
7
|
+
gem 'test-unit'
|
8
|
+
|
9
|
+
require 'test/unit'
|
10
|
+
require 'html/table'
|
8
11
|
include HTML
|
9
12
|
|
10
13
|
class TC_HTML_Table_Col < Test::Unit::TestCase
|
11
14
|
def setup
|
12
|
-
@
|
13
|
-
@
|
15
|
+
@col = Table::ColGroup::Col.new
|
16
|
+
@cgroup = Table::ColGroup.new
|
14
17
|
end
|
15
18
|
|
16
19
|
def test_basic
|
17
20
|
html = "<col>"
|
18
|
-
assert_equal(html
|
21
|
+
assert_equal(html, @col.html.gsub(/\s{2,}|\n+/,''))
|
19
22
|
end
|
20
23
|
|
21
24
|
def test_no_configure
|
22
|
-
assert_raises(NoMethodError){ @
|
25
|
+
assert_raises(NoMethodError){ @col.configure }
|
23
26
|
end
|
24
27
|
|
25
28
|
def test_no_content_allowed
|
26
|
-
assert_raises(NoMethodError){ @
|
27
|
-
assert_raises(NoMethodError){ @
|
29
|
+
assert_raises(NoMethodError){ @col.content }
|
30
|
+
assert_raises(NoMethodError){ @col.content = "foo" }
|
28
31
|
end
|
29
32
|
|
30
33
|
def test_indent_level
|
@@ -35,6 +38,6 @@ class TC_HTML_Table_Col < Test::Unit::TestCase
|
|
35
38
|
end
|
36
39
|
|
37
40
|
def teardown
|
38
|
-
@
|
41
|
+
@col = nil
|
39
42
|
end
|
40
43
|
end
|
@@ -1,15 +1,18 @@
|
|
1
1
|
############################################
|
2
|
-
#
|
2
|
+
# test_colgroup.rb
|
3
3
|
#
|
4
4
|
# Test suite for the Table::ColGroup class
|
5
5
|
############################################
|
6
|
-
require
|
7
|
-
|
6
|
+
require 'rubygems'
|
7
|
+
gem 'test-unit'
|
8
|
+
|
9
|
+
require 'test/unit'
|
10
|
+
require 'html/table'
|
8
11
|
include HTML
|
9
12
|
|
10
13
|
class TC_HTML_Table_ColGroup < Test::Unit::TestCase
|
11
14
|
def setup
|
12
|
-
@
|
15
|
+
@cgroup = Table::ColGroup.new
|
13
16
|
@col = Table::ColGroup::Col.new
|
14
17
|
end
|
15
18
|
|
@@ -21,51 +24,51 @@ class TC_HTML_Table_ColGroup < Test::Unit::TestCase
|
|
21
24
|
|
22
25
|
def test_basic
|
23
26
|
html = "<colgroup></colgroup>"
|
24
|
-
assert_equal(html,@
|
27
|
+
assert_equal(html,@cgroup.html.gsub(/\s+/,''))
|
25
28
|
end
|
26
29
|
|
27
30
|
def test_with_attributes
|
28
31
|
html = "<colgroup align='center' width='20%'></colgroup>"
|
29
|
-
@
|
30
|
-
@
|
31
|
-
assert_equal(html,@
|
32
|
+
@cgroup.align = "center"
|
33
|
+
@cgroup.width = "20%"
|
34
|
+
assert_equal(html,@cgroup.html.gsub(/\s{2,}|\n+/,''))
|
32
35
|
end
|
33
36
|
|
34
37
|
def test_push_single_col_element
|
35
38
|
html = "<colgroup><col></colgroup>"
|
36
|
-
@
|
37
|
-
assert_equal(html,@
|
39
|
+
@cgroup.push(@col)
|
40
|
+
assert_equal(html,@cgroup.html.gsub(/\s{2,}|\n+/,''))
|
38
41
|
end
|
39
42
|
|
40
43
|
def test_index_assignment_constraints
|
41
|
-
assert_raises(ArgumentTypeError){ @
|
42
|
-
assert_raises(ArgumentTypeError){ @
|
43
|
-
assert_raises(ArgumentTypeError){ @
|
44
|
-
assert_nothing_raised{ @
|
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 }
|
45
48
|
end
|
46
49
|
|
47
50
|
def test_push_constraints
|
48
|
-
assert_raises(TypeError){ @
|
49
|
-
assert_raises(TypeError){ @
|
50
|
-
assert_raises(TypeError){ @
|
51
|
-
assert_nothing_raised{ @
|
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) }
|
52
55
|
end
|
53
56
|
|
54
57
|
# Test '<<'
|
55
58
|
def test_double_arrow_constraints
|
56
|
-
assert_raises(TypeError){ @
|
57
|
-
assert_raises(TypeError){ @
|
58
|
-
assert_raises(TypeError){ @
|
59
|
-
assert_nothing_raised{ @
|
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 }
|
60
63
|
end
|
61
64
|
|
62
65
|
def test_configure_error
|
63
|
-
assert_raises(ArgumentError){ @
|
66
|
+
assert_raises(ArgumentError){ @cgroup.configure(0,0){ } }
|
64
67
|
end
|
65
68
|
|
66
69
|
def test_content_error
|
67
|
-
assert_raises(NoMethodError){ @
|
68
|
-
assert_raises(NoMethodError){ @
|
70
|
+
assert_raises(NoMethodError){ @cgroup.content }
|
71
|
+
assert_raises(NoMethodError){ @cgroup.content = 'blah' }
|
69
72
|
end
|
70
73
|
|
71
74
|
def test_indent_level
|
@@ -84,6 +87,6 @@ class TC_HTML_Table_ColGroup < Test::Unit::TestCase
|
|
84
87
|
end
|
85
88
|
|
86
89
|
def teardown
|
87
|
-
@
|
90
|
+
@cgroup = nil
|
88
91
|
end
|
89
92
|
end
|
@@ -1,15 +1,18 @@
|
|
1
1
|
##############################################
|
2
|
-
#
|
2
|
+
# test_data.rb
|
3
3
|
#
|
4
4
|
# Test suite for the Table::Row::Data class
|
5
5
|
##############################################
|
6
|
-
require
|
7
|
-
|
6
|
+
require 'rubygems'
|
7
|
+
gem 'test-unit'
|
8
|
+
|
9
|
+
require 'test/unit'
|
10
|
+
require 'html/table'
|
8
11
|
include HTML
|
9
12
|
|
10
13
|
class TC_HTML_Table_Row_Data < Test::Unit::TestCase
|
11
14
|
def setup
|
12
|
-
@
|
15
|
+
@tdata = Table::Row::Data.new
|
13
16
|
end
|
14
17
|
|
15
18
|
def test_constructor
|
@@ -23,25 +26,25 @@ class TC_HTML_Table_Row_Data < Test::Unit::TestCase
|
|
23
26
|
|
24
27
|
def test_basic
|
25
28
|
html = "<td></td>"
|
26
|
-
assert_equal(html,@
|
29
|
+
assert_equal(html,@tdata.html.gsub(/\s+/,''))
|
27
30
|
end
|
28
31
|
|
29
32
|
def test_with_attributes
|
30
33
|
html = "<td align='left' width=3 nowrap></td>"
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@
|
34
|
-
assert_equal(html,@
|
34
|
+
@tdata.align = 'left'
|
35
|
+
@tdata.width = 3
|
36
|
+
@tdata.nowrap = true
|
37
|
+
assert_equal(html,@tdata.html.gsub(/\s{2,}|\n+/,''))
|
35
38
|
end
|
36
39
|
|
37
40
|
def test_configure_not_allowed
|
38
|
-
assert_raises(NoMethodError){ @
|
41
|
+
assert_raises(NoMethodError){ @tdata.configure }
|
39
42
|
end
|
40
43
|
|
41
44
|
def test_add_content
|
42
45
|
html = "<td>hello world</td>"
|
43
|
-
@
|
44
|
-
assert_equal(html,@
|
46
|
+
@tdata.content = "hello world"
|
47
|
+
assert_equal(html,@tdata.html.gsub(/\s{2,}/,''))
|
45
48
|
end
|
46
49
|
|
47
50
|
def test_add_content_in_constructor
|
@@ -52,8 +55,8 @@ class TC_HTML_Table_Row_Data < Test::Unit::TestCase
|
|
52
55
|
|
53
56
|
def test_add_multiple_content_items
|
54
57
|
html = "<td>hello world</td>"
|
55
|
-
@
|
56
|
-
assert_equal(html,@
|
58
|
+
@tdata.content = "hello"," world"
|
59
|
+
assert_equal(html,@tdata.html.gsub(/\s{2,}/,''))
|
57
60
|
end
|
58
61
|
|
59
62
|
def test_indent_level
|
@@ -72,6 +75,6 @@ class TC_HTML_Table_Row_Data < Test::Unit::TestCase
|
|
72
75
|
end
|
73
76
|
|
74
77
|
def teardown
|
75
|
-
@
|
78
|
+
@tdata = nil
|
76
79
|
end
|
77
80
|
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
###############################################################################
|
2
|
-
#
|
2
|
+
# test_foot.rb
|
3
3
|
#
|
4
4
|
# Test suite for the Table::Foot class. The Table::Foot class is a singleton
|
5
5
|
# class, so we have to take extra measures to ensure that a fresh instance
|
6
6
|
# is created between tests.
|
7
7
|
###############################################################################
|
8
|
-
require
|
9
|
-
|
8
|
+
require 'rubygems'
|
9
|
+
gem 'test-unit'
|
10
|
+
|
11
|
+
require 'test/unit'
|
12
|
+
require 'html/table'
|
10
13
|
include HTML
|
11
14
|
|
12
15
|
#####################################################################
|
@@ -22,8 +25,8 @@ end
|
|
22
25
|
|
23
26
|
class TC_HTML_Table_Foot < Test::Unit::TestCase
|
24
27
|
def setup
|
25
|
-
@
|
26
|
-
@
|
28
|
+
@table = Table.new
|
29
|
+
@tfoot = Table::Foot.create
|
27
30
|
end
|
28
31
|
|
29
32
|
def test_new_not_allowed
|
@@ -36,12 +39,12 @@ class TC_HTML_Table_Foot < Test::Unit::TestCase
|
|
36
39
|
assert_nothing_raised{ Table::Foot.create(1) }
|
37
40
|
assert_nothing_raised{ Table::Foot.create(%w/foo bar baz/) }
|
38
41
|
assert_nothing_raised{ Table::Foot.create([1,2,3]) }
|
39
|
-
assert_nothing_raised{ Table::Foot.create([[1,2,3],["foo","bar"]]) }
|
42
|
+
assert_nothing_raised{ Table::Foot.create([[1,2,3], ["foo","bar"]]) }
|
40
43
|
end
|
41
44
|
|
42
45
|
def test_basic
|
43
46
|
html = "<tfoot></tfoot>"
|
44
|
-
assert_equal(html
|
47
|
+
assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n/,''))
|
45
48
|
end
|
46
49
|
|
47
50
|
def test_end_tags
|
@@ -49,6 +52,9 @@ class TC_HTML_Table_Foot < Test::Unit::TestCase
|
|
49
52
|
assert_respond_to(Table::Foot, :end_tags=)
|
50
53
|
assert_nothing_raised{ Table::Foot.end_tags? }
|
51
54
|
assert_nothing_raised{ Table::Foot.end_tags = true }
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_end_tags_expected_errors
|
52
58
|
assert_raises(StrongTyping::ArgumentTypeError){
|
53
59
|
Table::Foot.end_tags = "foo"
|
54
60
|
}
|
@@ -56,53 +62,53 @@ class TC_HTML_Table_Foot < Test::Unit::TestCase
|
|
56
62
|
|
57
63
|
def test_with_attributes
|
58
64
|
html = "<tfoot align='left' char='x'></tfoot>"
|
59
|
-
@
|
60
|
-
@
|
61
|
-
assert_equal(html
|
65
|
+
@tfoot.align = "left"
|
66
|
+
@tfoot.char = 'x'
|
67
|
+
assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n/,''))
|
62
68
|
end
|
63
69
|
|
64
70
|
def test_push_single_row
|
65
71
|
html = "<tfoot><tr><td>test</td></tr></tfoot>"
|
66
|
-
@
|
67
|
-
assert_equal(html
|
72
|
+
@tfoot.push Table::Row.new{|r| r.content = "test"}
|
73
|
+
assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n/,''))
|
68
74
|
end
|
69
75
|
|
70
76
|
def test_push_multiple_rows
|
71
77
|
html = "<tfoot><tr><td>test</td></tr><tr><td>foo</td></tr></tfoot>"
|
72
78
|
r1 = Table::Row.new{|r| r.content = "test"}
|
73
79
|
r2 = Table::Row.new{|r| r.content = "foo"}
|
74
|
-
@
|
75
|
-
assert_equal(html
|
80
|
+
@tfoot.push r1, r2
|
81
|
+
assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n/,''))
|
76
82
|
end
|
77
83
|
|
78
84
|
def test_add_content_directly
|
79
85
|
html = "<tfoot><tr><td>hello</td><td>world</td></tr></tfoot>"
|
80
|
-
@
|
81
|
-
assert_equal(html
|
86
|
+
@tfoot.content = "hello","world"
|
87
|
+
assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n+/,''))
|
82
88
|
end
|
83
89
|
|
84
90
|
def test_add_content_in_constructor
|
85
91
|
html = "<tfoot><tr><td>hello</td><td>world</td></tr></tfoot>"
|
86
|
-
@
|
87
|
-
@
|
88
|
-
assert_equal(html
|
92
|
+
@tfoot.send(:refresh)
|
93
|
+
@tfoot = Table::Foot.create(["hello","world"])
|
94
|
+
assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n+/,''))
|
89
95
|
end
|
90
96
|
|
91
97
|
def test_configure_column
|
92
98
|
html = "<tfoot><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
|
93
99
|
html += "</td></tr></tfoot>"
|
94
|
-
@
|
95
|
-
@
|
96
|
-
|
97
|
-
|
98
|
-
|
100
|
+
@tfoot.content = "hello","world"
|
101
|
+
@tfoot.configure(0,1){ |data|
|
102
|
+
data.abbr = 'test'
|
103
|
+
data.width = 3
|
104
|
+
data.nowrap = true
|
99
105
|
}
|
100
|
-
assert_equal(html
|
106
|
+
assert_equal(html, @tfoot.html.gsub(/\s{2,}|\n+/,''))
|
101
107
|
end
|
102
108
|
|
103
109
|
def teardown
|
104
|
-
@
|
105
|
-
@
|
106
|
-
@
|
110
|
+
@table = nil
|
111
|
+
@tfoot.send(:refresh)
|
112
|
+
@tfoot = nil
|
107
113
|
end
|
108
114
|
end
|