html-table 1.3.1 → 1.3.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 +8 -1
- data/MANIFEST +0 -1
- data/Rakefile +24 -24
- data/doc/table_content.rdoc +15 -15
- data/html-table-1.3.2.gem +0 -0
- data/html-table.gemspec +25 -0
- data/lib/html/attribute_handler.rb +411 -411
- data/lib/html/body.rb +38 -38
- data/lib/html/caption.rb +48 -46
- data/lib/html/col.rb +41 -38
- data/lib/html/colgroup.rb +113 -110
- data/lib/html/content.rb +18 -18
- data/lib/html/data.rb +68 -65
- 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 -185
- data/lib/html/table.rb +311 -255
- data/lib/html/tablesection.rb +48 -45
- data/lib/html/tag_handler.rb +123 -123
- data/test/tc_attribute_handler.rb +263 -273
- data/test/tc_body.rb +87 -97
- data/test/tc_caption.rb +80 -90
- data/test/tc_col.rb +40 -50
- data/test/tc_colgroup.rb +89 -99
- data/test/tc_data.rb +77 -87
- data/test/tc_foot.rb +108 -118
- data/test/tc_head.rb +104 -114
- data/test/tc_header.rb +77 -87
- data/test/tc_html_handler.rb +37 -47
- data/test/tc_row.rb +141 -151
- data/test/tc_table.rb +154 -163
- data/test/tc_tablesection.rb +42 -52
- data/test/tc_tag_handler.rb +82 -92
- metadata +29 -10
- data/test/ts_all.rb +0 -24
data/lib/html/tablesection.rb
CHANGED
@@ -1,45 +1,48 @@
|
|
1
|
-
module HTML
|
2
|
-
# Superclass for THEAD, TBODY, TFOOT
|
3
|
-
#
|
4
|
-
class Table::TableSection < Array
|
5
|
-
include AttributeHandler
|
6
|
-
include HtmlHandler
|
7
|
-
|
8
|
-
def initialize(&block)
|
9
|
-
instance_eval(&block) if block_given?
|
10
|
-
end
|
11
|
-
|
12
|
-
# Adds a Table::Row object as content. The +arg+ is passed as the value
|
13
|
-
# to the Table::Row constructor.
|
14
|
-
#
|
15
|
-
def content=(arg)
|
16
|
-
tr = Table::Row.new(arg)
|
17
|
-
self.push(tr)
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.indent_level
|
21
|
-
@indent_level
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.indent_level=(num)
|
25
|
-
expect(num, Integer)
|
26
|
-
raise ArgumentError, "indent_level must be >= 0" if num < 0
|
27
|
-
@indent_level = num
|
28
|
-
end
|
29
|
-
|
30
|
-
def []=(index,obj)
|
31
|
-
expect(obj,Table::Row)
|
32
|
-
super
|
33
|
-
end
|
34
|
-
|
35
|
-
def push(*args)
|
36
|
-
args.each{ |obj| expect(obj,Table::Row) }
|
37
|
-
super
|
38
|
-
end
|
39
|
-
|
40
|
-
def unshift(obj)
|
41
|
-
expect(obj,Table::Row)
|
42
|
-
super
|
43
|
-
end
|
44
|
-
|
45
|
-
|
1
|
+
module HTML
|
2
|
+
# Superclass for THEAD, TBODY, TFOOT
|
3
|
+
#
|
4
|
+
class Table::TableSection < Array
|
5
|
+
include AttributeHandler
|
6
|
+
include HtmlHandler
|
7
|
+
|
8
|
+
def initialize(&block)
|
9
|
+
instance_eval(&block) if block_given?
|
10
|
+
end
|
11
|
+
|
12
|
+
# Adds a Table::Row object as content. The +arg+ is passed as the value
|
13
|
+
# to the Table::Row constructor.
|
14
|
+
#
|
15
|
+
def content=(arg)
|
16
|
+
tr = Table::Row.new(arg)
|
17
|
+
self.push(tr)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.indent_level
|
21
|
+
@indent_level
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.indent_level=(num)
|
25
|
+
expect(num, Integer)
|
26
|
+
raise ArgumentError, "indent_level must be >= 0" if num < 0
|
27
|
+
@indent_level = num
|
28
|
+
end
|
29
|
+
|
30
|
+
def []=(index,obj)
|
31
|
+
expect(obj,Table::Row)
|
32
|
+
super
|
33
|
+
end
|
34
|
+
|
35
|
+
def push(*args)
|
36
|
+
args.each{ |obj| expect(obj,Table::Row) }
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
40
|
+
def unshift(obj)
|
41
|
+
expect(obj,Table::Row)
|
42
|
+
super
|
43
|
+
end
|
44
|
+
|
45
|
+
alias to_s html
|
46
|
+
alias to_str html
|
47
|
+
end
|
48
|
+
end
|
data/lib/html/tag_handler.rb
CHANGED
@@ -1,123 +1,123 @@
|
|
1
|
-
###################################################################
|
2
|
-
# tag_handler.rb
|
3
|
-
#
|
4
|
-
# Module for handling standard html physical tags (<b>, <i>, etc).
|
5
|
-
# Only used for Table::Content objects, which are in turn used by
|
6
|
-
# Table::Row::Data, Table::Row::Header and Table::Caption.
|
7
|
-
###################################################################
|
8
|
-
module TagHandler
|
9
|
-
def bold(bool = nil)
|
10
|
-
@bold ||= nil
|
11
|
-
self.bold = bool if bool
|
12
|
-
@bold
|
13
|
-
end
|
14
|
-
|
15
|
-
def bold=(bool)
|
16
|
-
handle_physical_tag('b', bool)
|
17
|
-
@bold = bool
|
18
|
-
end
|
19
|
-
|
20
|
-
def big(bool = nil)
|
21
|
-
@big ||= nil
|
22
|
-
self.big = bool if bool
|
23
|
-
@big
|
24
|
-
end
|
25
|
-
|
26
|
-
def big=(bool)
|
27
|
-
handle_physical_tag('big', bool)
|
28
|
-
@big = bool
|
29
|
-
end
|
30
|
-
|
31
|
-
def blink(bool = nil)
|
32
|
-
@blink ||= nil
|
33
|
-
self.blink = bool if bool
|
34
|
-
@blink
|
35
|
-
end
|
36
|
-
|
37
|
-
def blink=(bool)
|
38
|
-
if $VERBOSE
|
39
|
-
STDERR.puts("The 'blink' tag is very annoying. Please reconsider.")
|
40
|
-
end
|
41
|
-
handle_physical_tag('blink', bool)
|
42
|
-
@blink = bool
|
43
|
-
end
|
44
|
-
|
45
|
-
def italic(bool = nil)
|
46
|
-
@italic ||= nil
|
47
|
-
self.italic = bool if bool
|
48
|
-
@italic
|
49
|
-
end
|
50
|
-
|
51
|
-
def italic=(bool)
|
52
|
-
handle_physical_tag('i', bool)
|
53
|
-
@italic = bool
|
54
|
-
end
|
55
|
-
|
56
|
-
def strike(bool = nil)
|
57
|
-
@strike ||= nil
|
58
|
-
self.strike = bool if bool
|
59
|
-
@strike
|
60
|
-
end
|
61
|
-
|
62
|
-
def strike=(bool)
|
63
|
-
handle_physical_tag('strike', bool)
|
64
|
-
@strike = bool
|
65
|
-
end
|
66
|
-
|
67
|
-
def sub(bool = nil)
|
68
|
-
@sub ||= nil
|
69
|
-
self.sub = bool if bool
|
70
|
-
@sub
|
71
|
-
end
|
72
|
-
|
73
|
-
def sub=(bool)
|
74
|
-
handle_physical_tag('sub', bool)
|
75
|
-
@sub = bool
|
76
|
-
end
|
77
|
-
|
78
|
-
def sup(bool = nil)
|
79
|
-
@sup ||= nil
|
80
|
-
self.sup = bool if bool
|
81
|
-
@sup
|
82
|
-
end
|
83
|
-
|
84
|
-
def sup=(bool)
|
85
|
-
handle_physical_tag('sup', bool)
|
86
|
-
@sup = bool
|
87
|
-
end
|
88
|
-
|
89
|
-
def tt(bool = nil)
|
90
|
-
@tt ||= nil
|
91
|
-
self.tt = bool if bool
|
92
|
-
@tt
|
93
|
-
end
|
94
|
-
|
95
|
-
def tt=(bool)
|
96
|
-
handle_physical_tag('tt', bool)
|
97
|
-
@tt = bool
|
98
|
-
end
|
99
|
-
|
100
|
-
def underline(bool = nil)
|
101
|
-
@underline ||= nil
|
102
|
-
self.underline = bool if bool
|
103
|
-
@underline
|
104
|
-
end
|
105
|
-
|
106
|
-
def underline=(bool)
|
107
|
-
handle_physical_tag('u', bool)
|
108
|
-
@bool = bool
|
109
|
-
end
|
110
|
-
|
111
|
-
private
|
112
|
-
|
113
|
-
def handle_physical_tag(tag, bool)
|
114
|
-
begin_tag = "<#{tag}>"
|
115
|
-
end_tag = "</#{tag}>"
|
116
|
-
|
117
|
-
if bool
|
118
|
-
self.replace(begin_tag << self << end_tag)
|
119
|
-
else
|
120
|
-
self.replace(self.gsub(/#{begin_tag}|#{end_tag}/,''))
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
1
|
+
###################################################################
|
2
|
+
# tag_handler.rb
|
3
|
+
#
|
4
|
+
# Module for handling standard html physical tags (<b>, <i>, etc).
|
5
|
+
# Only used for Table::Content objects, which are in turn used by
|
6
|
+
# Table::Row::Data, Table::Row::Header and Table::Caption.
|
7
|
+
###################################################################
|
8
|
+
module TagHandler
|
9
|
+
def bold(bool = nil)
|
10
|
+
@bold ||= nil
|
11
|
+
self.bold = bool if bool
|
12
|
+
@bold
|
13
|
+
end
|
14
|
+
|
15
|
+
def bold=(bool)
|
16
|
+
handle_physical_tag('b', bool)
|
17
|
+
@bold = bool
|
18
|
+
end
|
19
|
+
|
20
|
+
def big(bool = nil)
|
21
|
+
@big ||= nil
|
22
|
+
self.big = bool if bool
|
23
|
+
@big
|
24
|
+
end
|
25
|
+
|
26
|
+
def big=(bool)
|
27
|
+
handle_physical_tag('big', bool)
|
28
|
+
@big = bool
|
29
|
+
end
|
30
|
+
|
31
|
+
def blink(bool = nil)
|
32
|
+
@blink ||= nil
|
33
|
+
self.blink = bool if bool
|
34
|
+
@blink
|
35
|
+
end
|
36
|
+
|
37
|
+
def blink=(bool)
|
38
|
+
if $VERBOSE
|
39
|
+
STDERR.puts("The 'blink' tag is very annoying. Please reconsider.")
|
40
|
+
end
|
41
|
+
handle_physical_tag('blink', bool)
|
42
|
+
@blink = bool
|
43
|
+
end
|
44
|
+
|
45
|
+
def italic(bool = nil)
|
46
|
+
@italic ||= nil
|
47
|
+
self.italic = bool if bool
|
48
|
+
@italic
|
49
|
+
end
|
50
|
+
|
51
|
+
def italic=(bool)
|
52
|
+
handle_physical_tag('i', bool)
|
53
|
+
@italic = bool
|
54
|
+
end
|
55
|
+
|
56
|
+
def strike(bool = nil)
|
57
|
+
@strike ||= nil
|
58
|
+
self.strike = bool if bool
|
59
|
+
@strike
|
60
|
+
end
|
61
|
+
|
62
|
+
def strike=(bool)
|
63
|
+
handle_physical_tag('strike', bool)
|
64
|
+
@strike = bool
|
65
|
+
end
|
66
|
+
|
67
|
+
def sub(bool = nil)
|
68
|
+
@sub ||= nil
|
69
|
+
self.sub = bool if bool
|
70
|
+
@sub
|
71
|
+
end
|
72
|
+
|
73
|
+
def sub=(bool)
|
74
|
+
handle_physical_tag('sub', bool)
|
75
|
+
@sub = bool
|
76
|
+
end
|
77
|
+
|
78
|
+
def sup(bool = nil)
|
79
|
+
@sup ||= nil
|
80
|
+
self.sup = bool if bool
|
81
|
+
@sup
|
82
|
+
end
|
83
|
+
|
84
|
+
def sup=(bool)
|
85
|
+
handle_physical_tag('sup', bool)
|
86
|
+
@sup = bool
|
87
|
+
end
|
88
|
+
|
89
|
+
def tt(bool = nil)
|
90
|
+
@tt ||= nil
|
91
|
+
self.tt = bool if bool
|
92
|
+
@tt
|
93
|
+
end
|
94
|
+
|
95
|
+
def tt=(bool)
|
96
|
+
handle_physical_tag('tt', bool)
|
97
|
+
@tt = bool
|
98
|
+
end
|
99
|
+
|
100
|
+
def underline(bool = nil)
|
101
|
+
@underline ||= nil
|
102
|
+
self.underline = bool if bool
|
103
|
+
@underline
|
104
|
+
end
|
105
|
+
|
106
|
+
def underline=(bool)
|
107
|
+
handle_physical_tag('u', bool)
|
108
|
+
@bool = bool
|
109
|
+
end
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
def handle_physical_tag(tag, bool)
|
114
|
+
begin_tag = "<#{tag}>"
|
115
|
+
end_tag = "</#{tag}>"
|
116
|
+
|
117
|
+
if bool
|
118
|
+
self.replace(begin_tag << self << end_tag)
|
119
|
+
else
|
120
|
+
self.replace(self.gsub(/#{begin_tag}|#{end_tag}/,''))
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -1,273 +1,263 @@
|
|
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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
assert_nothing_raised{ @table.
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
assert_respond_to(@table, :
|
65
|
-
|
66
|
-
assert_nothing_raised{ @table.
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
assert_nothing_raised{ @table.
|
168
|
-
assert_nothing_raised{ @table.
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
assert_nothing_raised{ @table.
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
assert_nothing_raised{ @table.width}
|
265
|
-
assert_nothing_raised{ @table.width = 10 }
|
266
|
-
assert_nothing_raised{ @table.width = '5%' }
|
267
|
-
assert_raises(ArgumentError){ @table.width = -1 }
|
268
|
-
end
|
269
|
-
|
270
|
-
def teardown
|
271
|
-
@table = nil
|
272
|
-
end
|
273
|
-
end
|
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
|
+
require 'test/unit'
|
8
|
+
require 'html/table'
|
9
|
+
include HTML
|
10
|
+
|
11
|
+
class TC_AttributeHandler < Test::Unit::TestCase
|
12
|
+
def setup
|
13
|
+
@table = Table.new(['foo',1,'bar'])
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_abbr
|
17
|
+
assert_respond_to(@table, :abbr)
|
18
|
+
assert_respond_to(@table, :abbr=)
|
19
|
+
assert_nothing_raised{ @table.abbr }
|
20
|
+
assert_nothing_raised{ @table.abbr = 'foo' }
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_align
|
24
|
+
assert_respond_to(@table, :align)
|
25
|
+
assert_respond_to(@table, :align=)
|
26
|
+
assert_nothing_raised{ @table.align }
|
27
|
+
assert_nothing_raised{ @table.align = 'center' }
|
28
|
+
assert_raises(ArgumentError){ @table.align = 'foo' }
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_axis
|
32
|
+
assert_respond_to(@table, :axis)
|
33
|
+
assert_respond_to(@table, :axis=)
|
34
|
+
assert_nothing_raised{ @table.axis }
|
35
|
+
assert_nothing_raised{ @table.axis = 'foo' }
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_background
|
39
|
+
assert_respond_to(@table, :background)
|
40
|
+
assert_respond_to(@table, :background=)
|
41
|
+
assert_nothing_raised{ @table.background }
|
42
|
+
assert_nothing_raised{ @table.background = 'foo' }
|
43
|
+
assert_raises(TypeError){ @table.background = 1 }
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_bgcolor
|
47
|
+
assert_respond_to(@table, :bgcolor)
|
48
|
+
assert_respond_to(@table, :bgcolor=)
|
49
|
+
assert_nothing_raised{ @table.bgcolor }
|
50
|
+
assert_nothing_raised{ @table.bgcolor = 'foo' }
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_border
|
54
|
+
assert_respond_to(@table, :border)
|
55
|
+
assert_respond_to(@table, :border=)
|
56
|
+
assert_nothing_raised{ @table.border }
|
57
|
+
assert_nothing_raised{ @table.border = 2 }
|
58
|
+
assert_nothing_raised{ @table.border = true }
|
59
|
+
assert_nothing_raised{ @table.border = false }
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_bordercolor
|
63
|
+
assert_respond_to(@table, :bordercolor)
|
64
|
+
assert_respond_to(@table, :bordercolor=)
|
65
|
+
assert_nothing_raised{ @table.bordercolor }
|
66
|
+
assert_nothing_raised{ @table.bordercolor = 'foo' }
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_bordercolordark
|
70
|
+
assert_respond_to(@table, :bordercolordark)
|
71
|
+
assert_respond_to(@table, :bordercolordark=)
|
72
|
+
assert_nothing_raised{ @table.bordercolordark }
|
73
|
+
assert_nothing_raised{ @table.bordercolordark = 'foo' }
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_bordercolorlight
|
77
|
+
assert_respond_to(@table, :bordercolorlight)
|
78
|
+
assert_respond_to(@table, :bordercolorlight=)
|
79
|
+
assert_nothing_raised{ @table.bordercolorlight }
|
80
|
+
assert_nothing_raised{ @table.bordercolorlight = 'foo' }
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_cellpadding
|
84
|
+
assert_respond_to(@table, :cellpadding)
|
85
|
+
assert_respond_to(@table, :cellpadding=)
|
86
|
+
assert_nothing_raised{ @table.cellpadding }
|
87
|
+
assert_nothing_raised{ @table.cellpadding = 1 }
|
88
|
+
assert_raises(ArgumentError){ @table.cellpadding = -1 }
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_cellspacing
|
92
|
+
assert_respond_to(@table, :cellspacing)
|
93
|
+
assert_respond_to(@table, :cellspacing=)
|
94
|
+
assert_nothing_raised{ @table.cellspacing }
|
95
|
+
assert_nothing_raised{ @table.cellspacing = 1 }
|
96
|
+
assert_raises(ArgumentError){ @table.cellspacing = -1 }
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_char
|
100
|
+
assert_respond_to(@table, :char)
|
101
|
+
assert_respond_to(@table, :char=)
|
102
|
+
assert_nothing_raised{ @table.char }
|
103
|
+
assert_nothing_raised{ @table.char = 'x' }
|
104
|
+
assert_raises(ArgumentError){ @table.char = 'xx' }
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_charoff
|
108
|
+
assert_respond_to(@table, :charoff)
|
109
|
+
assert_respond_to(@table, :charoff=)
|
110
|
+
assert_nothing_raised{ @table.charoff }
|
111
|
+
assert_nothing_raised{ @table.charoff = 1 }
|
112
|
+
assert_raises(ArgumentError){ @table.charoff = -1 }
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_class
|
116
|
+
assert_respond_to(@table, :class_)
|
117
|
+
assert_respond_to(@table, :class_=)
|
118
|
+
assert_nothing_raised{ @table.class_ }
|
119
|
+
assert_nothing_raised{ @table.class_ = 'myclass' }
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_col
|
123
|
+
assert_respond_to(@table, :col)
|
124
|
+
assert_respond_to(@table, :col=)
|
125
|
+
assert_nothing_raised{ @table.col }
|
126
|
+
assert_nothing_raised{ @table.col = 1 }
|
127
|
+
assert_raises(ArgumentError){ @table.col = -1 }
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_colspan
|
131
|
+
assert_respond_to(@table, :colspan)
|
132
|
+
assert_respond_to(@table, :colspan=)
|
133
|
+
assert_nothing_raised{ @table.colspan }
|
134
|
+
assert_nothing_raised{ @table.colspan = 1 }
|
135
|
+
assert_raises(ArgumentError){ @table.colspan = -1 }
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_configure
|
139
|
+
assert_respond_to(@table, :configure)
|
140
|
+
assert_nothing_raised{ @table.configure(0){} }
|
141
|
+
assert_nothing_raised{ @table.configure(0,0){} }
|
142
|
+
assert_raises(ArgumentError){ @table.configure(0,0,0){} }
|
143
|
+
end
|
144
|
+
|
145
|
+
########################################################################
|
146
|
+
# This test could probably be broken out into separate tests for each
|
147
|
+
# type that we want to add as content.
|
148
|
+
########################################################################
|
149
|
+
def test_content
|
150
|
+
assert_respond_to(@table, :content)
|
151
|
+
assert_respond_to(@table, :content=)
|
152
|
+
assert_nothing_raised{ @table.content = 'foo' }
|
153
|
+
assert_nothing_raised{ @table.content = 123 }
|
154
|
+
assert_nothing_raised{ @table.content = ['one',2,'three'] }
|
155
|
+
assert_nothing_raised{ @table.content = [['foo','bar'],[1,2,3]] }
|
156
|
+
assert_nothing_raised{ @table.content = Table::Row.new }
|
157
|
+
assert_nothing_raised{ @table.content = Table::Row::Data.new }
|
158
|
+
assert_nothing_raised{ @table.content = Table::Row::Header.new }
|
159
|
+
assert_nothing_raised{ @table.content = Table::Head.create }
|
160
|
+
assert_nothing_raised{ @table.content = Table::Foot.create }
|
161
|
+
assert_nothing_raised{ @table.content = Table::Body.new }
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_frame
|
165
|
+
assert_respond_to(@table, :frame)
|
166
|
+
assert_respond_to(@table, :frame=)
|
167
|
+
assert_nothing_raised{ @table.frame }
|
168
|
+
assert_nothing_raised{ @table.frame = 'below' }
|
169
|
+
assert_raises(ArgumentError){ @table.frame = 'foo' }
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_height
|
173
|
+
assert_respond_to(@table, :height)
|
174
|
+
assert_respond_to(@table, :height=)
|
175
|
+
assert_nothing_raised{ @table.height }
|
176
|
+
assert_nothing_raised{ @table.height = 1 }
|
177
|
+
assert_raises(ArgumentError){ @table.height = -1 }
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_hspace
|
181
|
+
assert_respond_to(@table, :hspace)
|
182
|
+
assert_respond_to(@table, :hspace=)
|
183
|
+
assert_nothing_raised{ @table.hspace }
|
184
|
+
assert_nothing_raised{ @table.hspace = 1 }
|
185
|
+
assert_raises(ArgumentError){ @table.hspace = -1 }
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_nowrap
|
189
|
+
assert_respond_to(@table, :nowrap)
|
190
|
+
assert_respond_to(@table, :nowrap=)
|
191
|
+
assert_nothing_raised{ @table.nowrap }
|
192
|
+
assert_nothing_raised{ @table.nowrap = false }
|
193
|
+
assert_raises(TypeError){ @table.nowrap = 'foo' }
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_rowspan
|
197
|
+
assert_respond_to(@table, :rowspan)
|
198
|
+
assert_respond_to(@table, :rowspan=)
|
199
|
+
assert_nothing_raised{ @table.rowspan }
|
200
|
+
assert_nothing_raised{ @table.rowspan = 1 }
|
201
|
+
assert_raises(ArgumentError){ @table.rowspan = -1 }
|
202
|
+
end
|
203
|
+
|
204
|
+
def test_rules
|
205
|
+
assert_respond_to(@table, :rules)
|
206
|
+
assert_respond_to(@table, :rules=)
|
207
|
+
assert_nothing_raised{ @table.rules }
|
208
|
+
assert_nothing_raised{ @table.rules = 'all' }
|
209
|
+
assert_raises(ArgumentError){ @table.rules = 'foo' }
|
210
|
+
end
|
211
|
+
|
212
|
+
def test_span
|
213
|
+
assert_respond_to(@table, :span)
|
214
|
+
assert_respond_to(@table, :span=)
|
215
|
+
assert_nothing_raised{ @table.span }
|
216
|
+
assert_nothing_raised{ @table.span = 1 }
|
217
|
+
assert_raises(ArgumentError){ @table.span = -1 }
|
218
|
+
end
|
219
|
+
|
220
|
+
def test_style
|
221
|
+
assert_respond_to(@table, :style)
|
222
|
+
assert_respond_to(@table, :style=)
|
223
|
+
assert_nothing_raised{ @table.style }
|
224
|
+
assert_nothing_raised{ @table.style = 'color: blue' }
|
225
|
+
end
|
226
|
+
|
227
|
+
def test_summary
|
228
|
+
assert_respond_to(@table, :summary)
|
229
|
+
assert_respond_to(@table, :summary=)
|
230
|
+
assert_nothing_raised{ @table.summary }
|
231
|
+
assert_nothing_raised{ @table.summary = 'foo' }
|
232
|
+
assert_nothing_raised{ @table.summary = 1 }
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_valign
|
236
|
+
assert_respond_to(@table, :valign)
|
237
|
+
assert_respond_to(@table, :valign=)
|
238
|
+
assert_nothing_raised{ @table.valign }
|
239
|
+
assert_nothing_raised{ @table.valign = 'center' }
|
240
|
+
assert_raises(ArgumentError){ @table.valign = 'foo' }
|
241
|
+
end
|
242
|
+
|
243
|
+
def test_vspace
|
244
|
+
assert_respond_to(@table, :vspace)
|
245
|
+
assert_respond_to(@table, :vspace=)
|
246
|
+
assert_nothing_raised{ @table.vspace }
|
247
|
+
assert_nothing_raised{ @table.vspace = 1 }
|
248
|
+
assert_raises(ArgumentError){ @table.vspace = -1 }
|
249
|
+
end
|
250
|
+
|
251
|
+
def test_width
|
252
|
+
assert_respond_to(@table, :width)
|
253
|
+
assert_respond_to(@table, :width=)
|
254
|
+
assert_nothing_raised{ @table.width}
|
255
|
+
assert_nothing_raised{ @table.width = 10 }
|
256
|
+
assert_nothing_raised{ @table.width = '5%' }
|
257
|
+
assert_raises(ArgumentError){ @table.width = -1 }
|
258
|
+
end
|
259
|
+
|
260
|
+
def teardown
|
261
|
+
@table = nil
|
262
|
+
end
|
263
|
+
end
|