html-table 1.2.2
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/CHANGES +72 -0
- data/MANIFEST +41 -0
- data/README +137 -0
- data/doc/attributes.rdoc +143 -0
- data/doc/table.rdoc +157 -0
- data/doc/table_body.rdoc +9 -0
- data/doc/table_caption.rdoc +9 -0
- data/doc/table_colgroup.rdoc +8 -0
- data/doc/table_colgroup_col.rdoc +9 -0
- data/doc/table_foot.rdoc +8 -0
- data/doc/table_head.rdoc +11 -0
- data/doc/table_row.rdoc +105 -0
- data/doc/table_row_data.rdoc +92 -0
- data/doc/table_row_header.rdoc +7 -0
- data/lib/html/attribute_handler.rb +308 -0
- data/lib/html/body.rb +34 -0
- data/lib/html/caption.rb +40 -0
- data/lib/html/col.rb +33 -0
- data/lib/html/colgroup.rb +99 -0
- data/lib/html/data.rb +56 -0
- data/lib/html/foot.rb +43 -0
- data/lib/html/head.rb +42 -0
- data/lib/html/header.rb +56 -0
- data/lib/html/html_handler.rb +94 -0
- data/lib/html/row.rb +129 -0
- data/lib/html/table.rb +227 -0
- data/lib/html/tablesection.rb +42 -0
- data/lib/html/tag_handler.rb +64 -0
- data/test/tc_attribute_handler.rb +259 -0
- data/test/tc_body.rb +97 -0
- data/test/tc_caption.rb +90 -0
- data/test/tc_col.rb +50 -0
- data/test/tc_colgroup.rb +99 -0
- data/test/tc_data.rb +87 -0
- data/test/tc_foot.rb +118 -0
- data/test/tc_head.rb +114 -0
- data/test/tc_header.rb +87 -0
- data/test/tc_html_handler.rb +47 -0
- data/test/tc_row.rb +138 -0
- data/test/tc_table.rb +163 -0
- data/test/tc_tablesection.rb +52 -0
- data/test/ts_all.rb +23 -0
- metadata +96 -0
@@ -0,0 +1,259 @@
|
|
1
|
+
############################################################################
|
2
|
+
# tc_attribute_handler.rb
|
3
|
+
#
|
4
|
+
# Test suite for the AttributeHandler module. For these tests, we'll use an
|
5
|
+
# instance of the Table class where the module has been mixed in.
|
6
|
+
############################################################################
|
7
|
+
base = File.basename(Dir.pwd)
|
8
|
+
|
9
|
+
if base == "test" || base =~ /html-table/
|
10
|
+
Dir.chdir("..") if base == "test"
|
11
|
+
$LOAD_PATH.unshift(Dir.pwd)
|
12
|
+
$LOAD_PATH.unshift(Dir.pwd + "/lib")
|
13
|
+
$LOAD_PATH.unshift(Dir.pwd + "/lib/html")
|
14
|
+
Dir.chdir("test") rescue nil
|
15
|
+
end
|
16
|
+
|
17
|
+
require "test/unit"
|
18
|
+
require "html/table"
|
19
|
+
include HTML
|
20
|
+
|
21
|
+
class TC_AttributeHandler < Test::Unit::TestCase
|
22
|
+
def setup
|
23
|
+
@t = Table.new(["foo",1,"bar"])
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_abbr
|
27
|
+
assert_respond_to(@t,:abbr)
|
28
|
+
assert_respond_to(@t,:abbr=)
|
29
|
+
assert_nothing_raised{ @t.abbr }
|
30
|
+
assert_nothing_raised{ @t.abbr="foo" }
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_align
|
34
|
+
assert_respond_to(@t,:align)
|
35
|
+
assert_respond_to(@t,:align=)
|
36
|
+
assert_nothing_raised{ @t.align }
|
37
|
+
assert_nothing_raised{ @t.align = "center" }
|
38
|
+
assert_raises(ArgumentError){ @t.align = "foo" }
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_axis
|
42
|
+
assert_respond_to(@t,:axis)
|
43
|
+
assert_respond_to(@t,:axis=)
|
44
|
+
assert_nothing_raised{ @t.axis }
|
45
|
+
assert_nothing_raised{ @t.axis="foo" }
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_background
|
49
|
+
assert_respond_to(@t,:background)
|
50
|
+
assert_respond_to(@t,:background=)
|
51
|
+
assert_nothing_raised{ @t.background }
|
52
|
+
assert_nothing_raised{ @t.background="foo" }
|
53
|
+
assert_raises(TypeError){ @t.background = 1 }
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_bgcolor
|
57
|
+
assert_respond_to(@t,:bgcolor)
|
58
|
+
assert_respond_to(@t,:bgcolor=)
|
59
|
+
assert_nothing_raised{ @t.bgcolor }
|
60
|
+
assert_nothing_raised{ @t.bgcolor="foo" }
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_border
|
64
|
+
assert_respond_to(@t,:border)
|
65
|
+
assert_respond_to(@t,:border=)
|
66
|
+
assert_nothing_raised{ @t.border }
|
67
|
+
assert_nothing_raised{ @t.border = 2 }
|
68
|
+
assert_nothing_raised{ @t.border = true }
|
69
|
+
assert_nothing_raised{ @t.border = false }
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_bordercolor
|
73
|
+
assert_respond_to(@t,:bordercolor)
|
74
|
+
assert_respond_to(@t,:bordercolor=)
|
75
|
+
assert_nothing_raised{ @t.bordercolor }
|
76
|
+
assert_nothing_raised{ @t.bordercolor="foo" }
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_bordercolordark
|
80
|
+
assert_respond_to(@t,:bordercolordark)
|
81
|
+
assert_respond_to(@t,:bordercolordark=)
|
82
|
+
assert_nothing_raised{ @t.bordercolordark }
|
83
|
+
assert_nothing_raised{ @t.bordercolordark="foo" }
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_bordercolorlight
|
87
|
+
assert_respond_to(@t,:bordercolorlight)
|
88
|
+
assert_respond_to(@t,:bordercolorlight=)
|
89
|
+
assert_nothing_raised{ @t.bordercolorlight }
|
90
|
+
assert_nothing_raised{ @t.bordercolorlight="foo" }
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_cellpadding
|
94
|
+
assert_respond_to(@t,:cellpadding)
|
95
|
+
assert_respond_to(@t,:cellpadding=)
|
96
|
+
assert_nothing_raised{ @t.cellpadding }
|
97
|
+
assert_nothing_raised{ @t.cellpadding=1 }
|
98
|
+
assert_raises(ArgumentError){ @t.cellpadding = -1 }
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_cellspacing
|
102
|
+
assert_respond_to(@t,:cellspacing)
|
103
|
+
assert_respond_to(@t,:cellspacing=)
|
104
|
+
assert_nothing_raised{ @t.cellspacing }
|
105
|
+
assert_nothing_raised{ @t.cellspacing=1 }
|
106
|
+
assert_raises(ArgumentError){ @t.cellspacing = -1 }
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_char
|
110
|
+
assert_respond_to(@t,:char)
|
111
|
+
assert_respond_to(@t,:char=)
|
112
|
+
assert_nothing_raised{ @t.char }
|
113
|
+
assert_nothing_raised{ @t.char="x" }
|
114
|
+
assert_raises(ArgumentError){ @t.char = "xx" }
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_charoff
|
118
|
+
assert_respond_to(@t,:charoff)
|
119
|
+
assert_respond_to(@t,:charoff=)
|
120
|
+
assert_nothing_raised{ @t.charoff }
|
121
|
+
assert_nothing_raised{ @t.charoff=1 }
|
122
|
+
assert_raises(ArgumentError){ @t.charoff = -1 }
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_col
|
126
|
+
assert_respond_to(@t,:col)
|
127
|
+
assert_respond_to(@t,:col=)
|
128
|
+
assert_nothing_raised{ @t.col }
|
129
|
+
assert_nothing_raised{ @t.col=1 }
|
130
|
+
assert_raises(ArgumentError){ @t.col = -1 }
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_colspan
|
134
|
+
assert_respond_to(@t,:colspan)
|
135
|
+
assert_respond_to(@t,:colspan=)
|
136
|
+
assert_nothing_raised{ @t.colspan }
|
137
|
+
assert_nothing_raised{ @t.colspan=1 }
|
138
|
+
assert_raises(ArgumentError){ @t.colspan = -1 }
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_configure
|
142
|
+
assert_respond_to(@t,:configure)
|
143
|
+
assert_nothing_raised{ @t.configure(0){} }
|
144
|
+
assert_nothing_raised{ @t.configure(0,0){} }
|
145
|
+
assert_raises(ArgumentError){ @t.configure(0,0,0){} }
|
146
|
+
end
|
147
|
+
|
148
|
+
########################################################################
|
149
|
+
# This test could probably be broken out into separate tests for each
|
150
|
+
# type that we want to add as content.
|
151
|
+
########################################################################
|
152
|
+
def test_content
|
153
|
+
assert_respond_to(@t,:content)
|
154
|
+
assert_respond_to(@t,:content=)
|
155
|
+
assert_nothing_raised{ @t.content = "foo" }
|
156
|
+
assert_nothing_raised{ @t.content = 123 }
|
157
|
+
assert_nothing_raised{ @t.content = ["one",2,"three"] }
|
158
|
+
assert_nothing_raised{ @t.content = [["foo","bar"],[1,2,3]] }
|
159
|
+
assert_nothing_raised{ @t.content = Table::Row.new }
|
160
|
+
assert_nothing_raised{ @t.content = Table::Row::Data.new }
|
161
|
+
assert_nothing_raised{ @t.content = Table::Row::Header.new }
|
162
|
+
assert_nothing_raised{ @t.content = Table::Head.create }
|
163
|
+
assert_nothing_raised{ @t.content = Table::Foot.create }
|
164
|
+
assert_nothing_raised{ @t.content = Table::Body.new }
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_frame
|
168
|
+
assert_respond_to(@t,:frame)
|
169
|
+
assert_respond_to(@t,:frame=)
|
170
|
+
assert_nothing_raised{ @t.frame }
|
171
|
+
assert_nothing_raised{ @t.frame="below" }
|
172
|
+
assert_raises(ArgumentError){ @t.frame = "foo" }
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_height
|
176
|
+
assert_respond_to(@t,:height)
|
177
|
+
assert_respond_to(@t,:height=)
|
178
|
+
assert_nothing_raised{ @t.height }
|
179
|
+
assert_nothing_raised{ @t.height=1 }
|
180
|
+
assert_raises(ArgumentError){ @t.height = -1 }
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_hspace
|
184
|
+
assert_respond_to(@t,:hspace)
|
185
|
+
assert_respond_to(@t,:hspace=)
|
186
|
+
assert_nothing_raised{ @t.hspace }
|
187
|
+
assert_nothing_raised{ @t.hspace=1 }
|
188
|
+
assert_raises(ArgumentError){ @t.hspace = -1 }
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_nowrap
|
192
|
+
assert_respond_to(@t,:nowrap)
|
193
|
+
assert_respond_to(@t,:nowrap=)
|
194
|
+
assert_nothing_raised{ @t.nowrap }
|
195
|
+
assert_nothing_raised{ @t.nowrap=false }
|
196
|
+
assert_raises(TypeError){ @t.nowrap = "foo" }
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_rowspan
|
200
|
+
assert_respond_to(@t,:rowspan)
|
201
|
+
assert_respond_to(@t,:rowspan=)
|
202
|
+
assert_nothing_raised{ @t.rowspan }
|
203
|
+
assert_nothing_raised{ @t.rowspan=1 }
|
204
|
+
assert_raises(ArgumentError){ @t.rowspan = -1 }
|
205
|
+
end
|
206
|
+
|
207
|
+
def test_rules
|
208
|
+
assert_respond_to(@t,:rules)
|
209
|
+
assert_respond_to(@t,:rules=)
|
210
|
+
assert_nothing_raised{ @t.rules}
|
211
|
+
assert_nothing_raised{ @t.rules="all" }
|
212
|
+
assert_raises(ArgumentError){ @t.rules = "foo" }
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_span
|
216
|
+
assert_respond_to(@t,:span)
|
217
|
+
assert_respond_to(@t,:span=)
|
218
|
+
assert_nothing_raised{ @t.span }
|
219
|
+
assert_nothing_raised{ @t.span=1 }
|
220
|
+
assert_raises(ArgumentError){ @t.span = -1 }
|
221
|
+
end
|
222
|
+
|
223
|
+
def test_summary
|
224
|
+
assert_respond_to(@t,:summary)
|
225
|
+
assert_respond_to(@t,:summary=)
|
226
|
+
assert_nothing_raised{ @t.summary }
|
227
|
+
assert_nothing_raised{ @t.summary="foo" }
|
228
|
+
assert_nothing_raised{ @t.summary=1 }
|
229
|
+
end
|
230
|
+
|
231
|
+
def test_valign
|
232
|
+
assert_respond_to(@t,:valign)
|
233
|
+
assert_respond_to(@t,:valign=)
|
234
|
+
assert_nothing_raised{ @t.valign }
|
235
|
+
assert_nothing_raised{ @t.valign="center" }
|
236
|
+
assert_raises(ArgumentError){ @t.valign="foo" }
|
237
|
+
end
|
238
|
+
|
239
|
+
def test_vspace
|
240
|
+
assert_respond_to(@t,:vspace)
|
241
|
+
assert_respond_to(@t,:vspace=)
|
242
|
+
assert_nothing_raised{ @t.vspace }
|
243
|
+
assert_nothing_raised{ @t.vspace=1 }
|
244
|
+
assert_raises(ArgumentError){ @t.vspace = -1 }
|
245
|
+
end
|
246
|
+
|
247
|
+
def test_width
|
248
|
+
assert_respond_to(@t,:width)
|
249
|
+
assert_respond_to(@t,:width=)
|
250
|
+
assert_nothing_raised{ @t.width}
|
251
|
+
assert_nothing_raised{ @t.width = 10 }
|
252
|
+
assert_nothing_raised{ @t.width = "5%" }
|
253
|
+
assert_raises(ArgumentError){ @t.width = -1 }
|
254
|
+
end
|
255
|
+
|
256
|
+
def teardown
|
257
|
+
@t = nil
|
258
|
+
end
|
259
|
+
end
|
data/test/tc_body.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
############################################
|
2
|
+
# tc_body.rb
|
3
|
+
#
|
4
|
+
# Test suite for the Table::Body class
|
5
|
+
############################################
|
6
|
+
base = File.basename(Dir.pwd)
|
7
|
+
|
8
|
+
if base == "test" || base =~ /html-table/
|
9
|
+
Dir.chdir("..") if base == "test"
|
10
|
+
$LOAD_PATH.unshift(Dir.pwd)
|
11
|
+
$LOAD_PATH.unshift(Dir.pwd + "/lib")
|
12
|
+
$LOAD_PATH.unshift(Dir.pwd + "/lib/html")
|
13
|
+
Dir.chdir("test") rescue nil
|
14
|
+
end
|
15
|
+
|
16
|
+
require "test/unit"
|
17
|
+
require "html/table"
|
18
|
+
include HTML
|
19
|
+
|
20
|
+
class TC_HTML_Table_Body < Test::Unit::TestCase
|
21
|
+
def setup
|
22
|
+
@t = Table.new
|
23
|
+
@tb = Table::Body.new
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_constructor
|
27
|
+
assert_nothing_raised{ Table::Body.new }
|
28
|
+
assert_nothing_raised{ Table::Body.new("foo") }
|
29
|
+
assert_nothing_raised{ Table::Body.new(1) }
|
30
|
+
assert_nothing_raised{ Table::Body.new(%w/foo bar baz/) }
|
31
|
+
assert_nothing_raised{ Table::Body.new([1,2,3]) }
|
32
|
+
assert_nothing_raised{ Table::Body.new([[1,2,3],["foo","bar"]]) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_basic
|
36
|
+
html = "<tbody></tbody>"
|
37
|
+
assert_equal(html,@tb.html.gsub(/\s{2,}|\n/,''))
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_with_attributes
|
41
|
+
html = "<tbody align='left' char='x'></tbody>"
|
42
|
+
@tb.align = "left"
|
43
|
+
@tb.char = 'x'
|
44
|
+
assert_equal(html,@tb.html.gsub(/\s{2,}|\n/,''))
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_push_single_row
|
48
|
+
html = "<tbody><tr><td>test</td></tr></tbody>"
|
49
|
+
@tb.push Table::Row.new{|r| r.content = "test"}
|
50
|
+
assert_equal(html,@tb.html.gsub(/\s{2,}|\n/,''))
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_push_multiple_rows
|
54
|
+
html = "<tbody><tr><td>test</td></tr><tr><td>foo</td></tr></tbody>"
|
55
|
+
r1 = Table::Row.new{|r| r.content = "test"}
|
56
|
+
r2 = Table::Row.new{|r| r.content = "foo"}
|
57
|
+
@tb.push r1, r2
|
58
|
+
assert_equal(html,@tb.html.gsub(/\s{2,}|\n/,''))
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_add_content_directly
|
62
|
+
html = "<tbody><tr><td>hello</td><td>world</td></tr></tbody>"
|
63
|
+
@tb.content = "hello","world"
|
64
|
+
assert_equal(html,@tb.html.gsub(/\s{2,}|\n+/,''))
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_add_content_in_constructor
|
68
|
+
html = "<tbody><tr><td>hello</td><td>world</td></tr></tbody>"
|
69
|
+
tb = Table::Body.new(%w/hello world/)
|
70
|
+
assert_equal(html,tb.html.gsub(/\s{2,}|\n+/,''))
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_configure_column
|
74
|
+
html = "<tbody><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
|
75
|
+
html += "</td></tr></tbody>"
|
76
|
+
@tb.content = "hello","world"
|
77
|
+
@tb.configure(0,1){ |d|
|
78
|
+
d.abbr = 'test'
|
79
|
+
d.width = 3
|
80
|
+
d.nowrap = true
|
81
|
+
}
|
82
|
+
assert_equal(html,@tb.html.gsub(/\s{2,}|\n+/,''))
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_end_tags
|
86
|
+
assert_respond_to(Table::Body,:end_tags?)
|
87
|
+
assert_respond_to(Table::Body,:end_tags=)
|
88
|
+
assert_raises(ArgumentTypeError){ Table::Body.end_tags = "foo" }
|
89
|
+
assert_raises(ArgumentTypeError){ Table::Body.end_tags = 1 }
|
90
|
+
assert_nothing_raised{ Table::Body.end_tags = true }
|
91
|
+
end
|
92
|
+
|
93
|
+
def teardown
|
94
|
+
@t = nil
|
95
|
+
@tb = nil
|
96
|
+
end
|
97
|
+
end
|
data/test/tc_caption.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
################################################
|
2
|
+
# tc_caption.rb
|
3
|
+
#
|
4
|
+
# Test suite for the Table::Caption class
|
5
|
+
################################################
|
6
|
+
base = File.basename(Dir.pwd)
|
7
|
+
|
8
|
+
if base == "test" || base =~ /html-table/
|
9
|
+
Dir.chdir("..") if base == "test"
|
10
|
+
$LOAD_PATH.unshift(Dir.pwd)
|
11
|
+
$LOAD_PATH.unshift(Dir.pwd + "/lib")
|
12
|
+
$LOAD_PATH.unshift(Dir.pwd + "/lib/html")
|
13
|
+
Dir.chdir("test") rescue nil
|
14
|
+
end
|
15
|
+
|
16
|
+
require "test/unit"
|
17
|
+
require "html/table"
|
18
|
+
include HTML
|
19
|
+
|
20
|
+
class TC_HTML_Table_Caption < Test::Unit::TestCase
|
21
|
+
def setup
|
22
|
+
@t = Table.new
|
23
|
+
@tc = Table::Caption.new
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_constructor
|
27
|
+
assert_nothing_raised{ Table::Caption.new }
|
28
|
+
assert_nothing_raised{ Table::Caption.new("foo") }
|
29
|
+
assert_nothing_raised{ Table::Caption.new(1) }
|
30
|
+
assert_nothing_raised{ Table::Caption.new(%w/foo bar baz/) }
|
31
|
+
assert_nothing_raised{ Table::Caption.new([1,2,3]) }
|
32
|
+
assert_nothing_raised{ Table::Caption.new([[1,2,3],["foo","bar"]]) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_basic
|
36
|
+
html = "<caption></caption>"
|
37
|
+
assert_equal(html,@tc.html.gsub(/\s+/,''))
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_with_attributes
|
41
|
+
html = "<caption align='left' valign='top'></caption>"
|
42
|
+
@tc.align = "left"
|
43
|
+
@tc.valign = "top"
|
44
|
+
assert_equal(html,@tc.html.gsub(/\s{2,}|\n+/,''))
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_configure_not_allowed
|
48
|
+
assert_raises(NoMethodError){ @tc.configure }
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_add_content
|
52
|
+
html = "<caption>hello world</caption>"
|
53
|
+
@tc.content = "hello world"
|
54
|
+
assert_equal(html,@tc.html.gsub(/\s{2,}/,''))
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_add_multiple_content_items
|
58
|
+
html = "<caption>hello world</caption>"
|
59
|
+
@tc.content = "hello"," world"
|
60
|
+
assert_equal(html,@tc.html.gsub(/\s{2,}/,''))
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_add_content_in_constructor
|
64
|
+
html = "<caption>hello world</caption>"
|
65
|
+
tc = Table::Caption.new("hello world")
|
66
|
+
assert_equal(html,tc.html.gsub(/\s{2,}/,''))
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_indent_level
|
70
|
+
assert_respond_to(Table::Caption,:indent_level)
|
71
|
+
assert_respond_to(Table::Caption,:indent_level=)
|
72
|
+
assert_raises(ArgumentTypeError){ Table::Caption.indent_level = "foo" }
|
73
|
+
assert_nothing_raised{ Table::Caption.indent_level = 3 }
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_only_row_zero
|
77
|
+
assert_raises(ArgumentError){ @t[1] = @tc }
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_automatically_set_to_row_zero
|
81
|
+
@t.content = "hello","world"
|
82
|
+
@t.push(@tc)
|
83
|
+
assert_equal(true,@t[0].kind_of?(Table::Caption))
|
84
|
+
end
|
85
|
+
|
86
|
+
def teardown
|
87
|
+
@t = nil
|
88
|
+
@tc = nil
|
89
|
+
end
|
90
|
+
end
|
data/test/tc_col.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
##################################################
|
2
|
+
# tc_col.rb
|
3
|
+
#
|
4
|
+
# Test suite for the Table::ColGroup::Col class
|
5
|
+
##################################################
|
6
|
+
base = File.basename(Dir.pwd)
|
7
|
+
|
8
|
+
if base == "test" || base =~ /html-table/
|
9
|
+
Dir.chdir("..") if base == "test"
|
10
|
+
$LOAD_PATH.unshift(Dir.pwd)
|
11
|
+
$LOAD_PATH.unshift(Dir.pwd + "/lib")
|
12
|
+
$LOAD_PATH.unshift(Dir.pwd + "/lib/html")
|
13
|
+
Dir.chdir("test") rescue nil
|
14
|
+
end
|
15
|
+
|
16
|
+
require "test/unit"
|
17
|
+
require "html/table"
|
18
|
+
include HTML
|
19
|
+
|
20
|
+
class TC_HTML_Table_Col < Test::Unit::TestCase
|
21
|
+
def setup
|
22
|
+
@c = Table::ColGroup::Col.new
|
23
|
+
@cg = Table::ColGroup.new
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_basic
|
27
|
+
html = "<col>"
|
28
|
+
assert_equal(html,@c.html.gsub(/\s{2,}|\n+/,''))
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_no_configure
|
32
|
+
assert_raises(NoMethodError){ @c.configure }
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_no_content_allowed
|
36
|
+
assert_raises(NoMethodError){ @c.content }
|
37
|
+
assert_raises(NoMethodError){ @c.content = "foo" }
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_indent_level
|
41
|
+
assert_respond_to(Table::ColGroup::Col,:indent_level)
|
42
|
+
assert_respond_to(Table::ColGroup::Col,:indent_level=)
|
43
|
+
assert_raises(ArgumentTypeError){ Table::ColGroup::Col.indent_level = "foo" }
|
44
|
+
assert_nothing_raised{ Table::ColGroup::Col.indent_level = 6 }
|
45
|
+
end
|
46
|
+
|
47
|
+
def teardown
|
48
|
+
@c = nil
|
49
|
+
end
|
50
|
+
end
|