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.
@@ -1,48 +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
- alias to_s html
46
- alias to_str html
47
- end
48
- end
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
@@ -1,121 +1,121 @@
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
- warn BlinkWarning, "The 'blink' tag is very annoying. Please reconsider."
39
- handle_physical_tag('blink', bool)
40
- @blink = bool
41
- end
42
-
43
- def italic(bool = nil)
44
- @italic ||= nil
45
- self.italic = bool if bool
46
- @italic
47
- end
48
-
49
- def italic=(bool)
50
- handle_physical_tag('i', bool)
51
- @italic = bool
52
- end
53
-
54
- def strike(bool = nil)
55
- @strike ||= nil
56
- self.strike = bool if bool
57
- @strike
58
- end
59
-
60
- def strike=(bool)
61
- handle_physical_tag('strike', bool)
62
- @strike = bool
63
- end
64
-
65
- def sub(bool = nil)
66
- @sub ||= nil
67
- self.sub = bool if bool
68
- @sub
69
- end
70
-
71
- def sub=(bool)
72
- handle_physical_tag('sub', bool)
73
- @sub = bool
74
- end
75
-
76
- def sup(bool = nil)
77
- @sup ||= nil
78
- self.sup = bool if bool
79
- @sup
80
- end
81
-
82
- def sup=(bool)
83
- handle_physical_tag('sup', bool)
84
- @sup = bool
85
- end
86
-
87
- def tt(bool = nil)
88
- @tt ||= nil
89
- self.tt = bool if bool
90
- @tt
91
- end
92
-
93
- def tt=(bool)
94
- handle_physical_tag('tt', bool)
95
- @tt = bool
96
- end
97
-
98
- def underline(bool = nil)
99
- @underline ||= nil
100
- self.underline = bool if bool
101
- @underline
102
- end
103
-
104
- def underline=(bool)
105
- handle_physical_tag('u', bool)
106
- @bool = bool
107
- end
108
-
109
- private
110
-
111
- def handle_physical_tag(tag, bool)
112
- begin_tag = "<#{tag}>"
113
- end_tag = "</#{tag}>"
114
-
115
- if bool
116
- self.replace(begin_tag << self << end_tag)
117
- else
118
- self.replace(self.gsub(/#{begin_tag}|#{end_tag}/,''))
119
- end
120
- end
121
- 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
+ warn BlinkWarning, "The 'blink' tag is very annoying. Please reconsider."
39
+ handle_physical_tag('blink', bool)
40
+ @blink = bool
41
+ end
42
+
43
+ def italic(bool = nil)
44
+ @italic ||= nil
45
+ self.italic = bool if bool
46
+ @italic
47
+ end
48
+
49
+ def italic=(bool)
50
+ handle_physical_tag('i', bool)
51
+ @italic = bool
52
+ end
53
+
54
+ def strike(bool = nil)
55
+ @strike ||= nil
56
+ self.strike = bool if bool
57
+ @strike
58
+ end
59
+
60
+ def strike=(bool)
61
+ handle_physical_tag('strike', bool)
62
+ @strike = bool
63
+ end
64
+
65
+ def sub(bool = nil)
66
+ @sub ||= nil
67
+ self.sub = bool if bool
68
+ @sub
69
+ end
70
+
71
+ def sub=(bool)
72
+ handle_physical_tag('sub', bool)
73
+ @sub = bool
74
+ end
75
+
76
+ def sup(bool = nil)
77
+ @sup ||= nil
78
+ self.sup = bool if bool
79
+ @sup
80
+ end
81
+
82
+ def sup=(bool)
83
+ handle_physical_tag('sup', bool)
84
+ @sup = bool
85
+ end
86
+
87
+ def tt(bool = nil)
88
+ @tt ||= nil
89
+ self.tt = bool if bool
90
+ @tt
91
+ end
92
+
93
+ def tt=(bool)
94
+ handle_physical_tag('tt', bool)
95
+ @tt = bool
96
+ end
97
+
98
+ def underline(bool = nil)
99
+ @underline ||= nil
100
+ self.underline = bool if bool
101
+ @underline
102
+ end
103
+
104
+ def underline=(bool)
105
+ handle_physical_tag('u', bool)
106
+ @bool = bool
107
+ end
108
+
109
+ private
110
+
111
+ def handle_physical_tag(tag, bool)
112
+ begin_tag = "<#{tag}>"
113
+ end_tag = "</#{tag}>"
114
+
115
+ if bool
116
+ self.replace(begin_tag << self << end_tag)
117
+ else
118
+ self.replace(self.gsub(/#{begin_tag}|#{end_tag}/,''))
119
+ end
120
+ end
121
+ end
@@ -1,364 +1,364 @@
1
- ############################################################################
2
- # test_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 'rubygems'
8
- gem 'test-unit'
9
-
10
- require 'test/unit'
11
- require 'html/table'
12
- include HTML
13
-
14
- class TC_AttributeHandler < Test::Unit::TestCase
15
- def self.startup
16
- NonStandardExtensionWarning.disable
17
- end
18
-
19
- def setup
20
- @table = Table.new(['foo',1,'bar'])
21
- end
22
-
23
- def test_abbr_basic
24
- assert_respond_to(@table, :abbr)
25
- assert_respond_to(@table, :abbr=)
26
- end
27
-
28
- def test_abbr
29
- assert_nothing_raised{ @table.abbr }
30
- assert_nil(@table.abbr)
31
- assert_nothing_raised{ @table.abbr = 'foo' }
32
- assert_equal('foo', @table.abbr)
33
- end
34
-
35
- def test_align_basic
36
- assert_respond_to(@table, :align)
37
- assert_respond_to(@table, :align=)
38
- end
39
-
40
- def test_align
41
- assert_nothing_raised{ @table.align }
42
- assert_nil(@table.align)
43
- assert_nothing_raised{ @table.align = 'center' }
44
- assert_equal('center', @table.align)
45
- end
46
-
47
- def test_align_expected_errors
48
- assert_raises(ArgumentError){ @table.align = 'foo' }
49
- end
50
-
51
- def test_axis
52
- assert_respond_to(@table, :axis)
53
- assert_respond_to(@table, :axis=)
54
- assert_nothing_raised{ @table.axis }
55
- assert_nothing_raised{ @table.axis = 'foo' }
56
- end
57
-
58
- def test_background_basic
59
- assert_respond_to(@table, :background)
60
- assert_respond_to(@table, :background=)
61
- end
62
-
63
- def test_background
64
- assert_nothing_raised{ @table.background }
65
- assert_nil(@table.background)
66
- assert_nothing_raised{ @table.background = 'foo' }
67
- assert_equal('foo', @table.background)
68
- end
69
-
70
- def test_background_expected_errors
71
- assert_raises(TypeError){ @table.background = 1 }
72
- end
73
-
74
- def test_bgcolor_basic
75
- assert_respond_to(@table, :bgcolor)
76
- assert_respond_to(@table, :bgcolor=)
77
- end
78
-
79
- def test_bgcolor
80
- assert_nothing_raised{ @table.bgcolor }
81
- assert_nil(@table.bgcolor)
82
- assert_nothing_raised{ @table.bgcolor = 'foo' }
83
- assert_equal('foo', @table.bgcolor)
84
- end
85
-
86
- def test_border_basic
87
- assert_respond_to(@table, :border)
88
- assert_respond_to(@table, :border=)
89
- end
90
-
91
- def test_border
92
- assert_nothing_raised{ @table.border }
93
- assert_nothing_raised{ @table.border = 2 }
94
- assert_nothing_raised{ @table.border = true }
95
- assert_nothing_raised{ @table.border = false }
96
- end
97
-
98
- def test_bordercolor_basic
99
- assert_respond_to(@table, :bordercolor)
100
- assert_respond_to(@table, :bordercolor=)
101
- end
102
-
103
- def test_bordercolor
104
- assert_nothing_raised{ @table.bordercolor }
105
- assert_nil(@table.bordercolor)
106
- assert_nothing_raised{ @table.bordercolor = 'foo' }
107
- assert_equal('foo', @table.bordercolor)
108
- end
109
-
110
- def test_bordercolordark_basic
111
- assert_respond_to(@table, :bordercolordark)
112
- assert_respond_to(@table, :bordercolordark=)
113
- end
114
-
115
- def test_bordercolordark
116
- assert_nothing_raised{ @table.bordercolordark }
117
- assert_nil(@table.bordercolordark)
118
- assert_nothing_raised{ @table.bordercolordark = 'foo' }
119
- assert_equal('foo', @table.bordercolordark)
120
- end
121
-
122
- def test_bordercolorlight
123
- assert_respond_to(@table, :bordercolorlight)
124
- assert_respond_to(@table, :bordercolorlight=)
125
- assert_nothing_raised{ @table.bordercolorlight }
126
- assert_nothing_raised{ @table.bordercolorlight = 'foo' }
127
- end
128
-
129
- def test_cellpadding
130
- assert_respond_to(@table, :cellpadding)
131
- assert_respond_to(@table, :cellpadding=)
132
- assert_nothing_raised{ @table.cellpadding }
133
- assert_nothing_raised{ @table.cellpadding = 1 }
134
- end
135
-
136
- def test_cellpadding_expected_errors
137
- assert_raises(ArgumentError){ @table.cellpadding = -1 }
138
- end
139
-
140
- def test_cellspacing
141
- assert_respond_to(@table, :cellspacing)
142
- assert_respond_to(@table, :cellspacing=)
143
- assert_nothing_raised{ @table.cellspacing }
144
- assert_nothing_raised{ @table.cellspacing = 1 }
145
- end
146
-
147
- def test_cellspacing_expected_errors
148
- assert_raises(ArgumentError){ @table.cellspacing = -1 }
149
- end
150
-
151
- def test_char
152
- assert_respond_to(@table, :char)
153
- assert_respond_to(@table, :char=)
154
- assert_nothing_raised{ @table.char }
155
- assert_nothing_raised{ @table.char = 'x' }
156
- end
157
-
158
- def test_char_expected_errors
159
- assert_raises(ArgumentError){ @table.char = 'xx' }
160
- end
161
-
162
- def test_charoff
163
- assert_respond_to(@table, :charoff)
164
- assert_respond_to(@table, :charoff=)
165
- assert_nothing_raised{ @table.charoff }
166
- assert_nothing_raised{ @table.charoff = 1 }
167
- end
168
-
169
- def test_charoff_expected_errors
170
- assert_raises(ArgumentError){ @table.charoff = -1 }
171
- end
172
-
173
- def test_class
174
- assert_respond_to(@table, :class_)
175
- assert_respond_to(@table, :class_=)
176
- assert_nothing_raised{ @table.class_ }
177
- assert_nothing_raised{ @table.class_ = 'myclass' }
178
- end
179
-
180
- def test_col
181
- assert_respond_to(@table, :col)
182
- assert_respond_to(@table, :col=)
183
- assert_nothing_raised{ @table.col }
184
- assert_nothing_raised{ @table.col = 1 }
185
- end
186
-
187
- def test_col_expected_errors
188
- assert_raises(ArgumentError){ @table.col = -1 }
189
- end
190
-
191
- def test_colspan
192
- assert_respond_to(@table, :colspan)
193
- assert_respond_to(@table, :colspan=)
194
- assert_nothing_raised{ @table.colspan }
195
- assert_nothing_raised{ @table.colspan = 1 }
196
- end
197
-
198
- def test_colspan_expected_errors
199
- assert_raises(ArgumentError){ @table.colspan = -1 }
200
- end
201
-
202
- def test_configure
203
- assert_respond_to(@table, :configure)
204
- assert_nothing_raised{ @table.configure(0){} }
205
- assert_nothing_raised{ @table.configure(0,0){} }
206
- end
207
-
208
- def test_configure_expected_errors
209
- assert_raises(ArgumentError){ @table.configure(0,0,0){} }
210
- end
211
-
212
- ########################################################################
213
- # This test could probably be broken out into separate tests for each
214
- # type that we want to add as content.
215
- ########################################################################
216
- def test_content
217
- assert_respond_to(@table, :content)
218
- assert_respond_to(@table, :content=)
219
- assert_nothing_raised{ @table.content = 'foo' }
220
- assert_nothing_raised{ @table.content = 123 }
221
- assert_nothing_raised{ @table.content = ['one',2,'three'] }
222
- assert_nothing_raised{ @table.content = [['foo','bar'],[1,2,3]] }
223
- assert_nothing_raised{ @table.content = Table::Row.new }
224
- assert_nothing_raised{ @table.content = Table::Row::Data.new }
225
- assert_nothing_raised{ @table.content = Table::Row::Header.new }
226
- assert_nothing_raised{ @table.content = Table::Head.create }
227
- assert_nothing_raised{ @table.content = Table::Foot.create }
228
- assert_nothing_raised{ @table.content = Table::Body.new }
229
- end
230
-
231
- def test_frame
232
- assert_respond_to(@table, :frame)
233
- assert_respond_to(@table, :frame=)
234
- assert_nothing_raised{ @table.frame }
235
- assert_nothing_raised{ @table.frame = 'below' }
236
- end
237
-
238
- def test_frame_expected_errors
239
- assert_raises(ArgumentError){ @table.frame = 'foo' }
240
- end
241
-
242
- def test_height
243
- assert_respond_to(@table, :height)
244
- assert_respond_to(@table, :height=)
245
- assert_nothing_raised{ @table.height }
246
- assert_nothing_raised{ @table.height = 1 }
247
- end
248
-
249
- def test_height_expected_errors
250
- assert_raises(ArgumentError){ @table.height = -1 }
251
- end
252
-
253
- def test_hspace
254
- assert_respond_to(@table, :hspace)
255
- assert_respond_to(@table, :hspace=)
256
- assert_nothing_raised{ @table.hspace }
257
- assert_nothing_raised{ @table.hspace = 1 }
258
- end
259
-
260
- def test_hspace_expected_errors
261
- assert_raises(ArgumentError){ @table.hspace = -1 }
262
- end
263
-
264
- def test_nowrap
265
- assert_respond_to(@table, :nowrap)
266
- assert_respond_to(@table, :nowrap=)
267
- assert_nothing_raised{ @table.nowrap }
268
- assert_nothing_raised{ @table.nowrap = false }
269
- end
270
-
271
- def test_nowrap_expected_errors
272
- assert_raises(TypeError){ @table.nowrap = 'foo' }
273
- end
274
-
275
- def test_rowspan
276
- assert_respond_to(@table, :rowspan)
277
- assert_respond_to(@table, :rowspan=)
278
- assert_nothing_raised{ @table.rowspan }
279
- assert_nothing_raised{ @table.rowspan = 1 }
280
- end
281
-
282
- def test_rowspan_expected_errors
283
- assert_raises(ArgumentError){ @table.rowspan = -1 }
284
- end
285
-
286
- def test_rules
287
- assert_respond_to(@table, :rules)
288
- assert_respond_to(@table, :rules=)
289
- assert_nothing_raised{ @table.rules }
290
- assert_nothing_raised{ @table.rules = 'all' }
291
- end
292
-
293
- def test_rules_expected_errors
294
- assert_raises(ArgumentError){ @table.rules = 'foo' }
295
- end
296
-
297
- def test_span
298
- assert_respond_to(@table, :span)
299
- assert_respond_to(@table, :span=)
300
- assert_nothing_raised{ @table.span }
301
- assert_nothing_raised{ @table.span = 1 }
302
- end
303
-
304
- def test_span_expected_errors
305
- assert_raises(ArgumentError){ @table.span = -1 }
306
- end
307
-
308
- def test_style
309
- assert_respond_to(@table, :style)
310
- assert_respond_to(@table, :style=)
311
- assert_nothing_raised{ @table.style }
312
- assert_nothing_raised{ @table.style = 'color: blue' }
313
- end
314
-
315
- def test_summary
316
- assert_respond_to(@table, :summary)
317
- assert_respond_to(@table, :summary=)
318
- assert_nothing_raised{ @table.summary }
319
- assert_nothing_raised{ @table.summary = 'foo' }
320
- assert_nothing_raised{ @table.summary = 1 }
321
- end
322
-
323
- def test_valign
324
- assert_respond_to(@table, :valign)
325
- assert_respond_to(@table, :valign=)
326
- assert_nothing_raised{ @table.valign }
327
- assert_nothing_raised{ @table.valign = 'center' }
328
- end
329
-
330
- def test_valign_expected_errors
331
- assert_raises(ArgumentError){ @table.valign = 'foo' }
332
- end
333
-
334
- def test_vspace
335
- assert_respond_to(@table, :vspace)
336
- assert_respond_to(@table, :vspace=)
337
- assert_nothing_raised{ @table.vspace }
338
- assert_nothing_raised{ @table.vspace = 1 }
339
- end
340
-
341
- def test_vspace_expected_errors
342
- assert_raises(ArgumentError){ @table.vspace = -1 }
343
- end
344
-
345
- def test_width
346
- assert_respond_to(@table, :width)
347
- assert_respond_to(@table, :width=)
348
- assert_nothing_raised{ @table.width}
349
- assert_nothing_raised{ @table.width = 10 }
350
- assert_nothing_raised{ @table.width = '5%' }
351
- end
352
-
353
- def test_width_expected_errors
354
- assert_raises(ArgumentError){ @table.width = -1 }
355
- end
356
-
357
- def teardown
358
- @table = nil
359
- end
360
-
361
- def self.shutdown
362
- NonStandardExtensionWarning.enable
363
- end
364
- end
1
+ ############################################################################
2
+ # test_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 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'test/unit'
11
+ require 'html/table'
12
+ include HTML
13
+
14
+ class TC_AttributeHandler < Test::Unit::TestCase
15
+ def self.startup
16
+ NonStandardExtensionWarning.disable
17
+ end
18
+
19
+ def setup
20
+ @table = Table.new(['foo',1,'bar'])
21
+ end
22
+
23
+ def test_abbr_basic
24
+ assert_respond_to(@table, :abbr)
25
+ assert_respond_to(@table, :abbr=)
26
+ end
27
+
28
+ def test_abbr
29
+ assert_nothing_raised{ @table.abbr }
30
+ assert_nil(@table.abbr)
31
+ assert_nothing_raised{ @table.abbr = 'foo' }
32
+ assert_equal('foo', @table.abbr)
33
+ end
34
+
35
+ def test_align_basic
36
+ assert_respond_to(@table, :align)
37
+ assert_respond_to(@table, :align=)
38
+ end
39
+
40
+ def test_align
41
+ assert_nothing_raised{ @table.align }
42
+ assert_nil(@table.align)
43
+ assert_nothing_raised{ @table.align = 'center' }
44
+ assert_equal('center', @table.align)
45
+ end
46
+
47
+ def test_align_expected_errors
48
+ assert_raises(ArgumentError){ @table.align = 'foo' }
49
+ end
50
+
51
+ def test_axis
52
+ assert_respond_to(@table, :axis)
53
+ assert_respond_to(@table, :axis=)
54
+ assert_nothing_raised{ @table.axis }
55
+ assert_nothing_raised{ @table.axis = 'foo' }
56
+ end
57
+
58
+ def test_background_basic
59
+ assert_respond_to(@table, :background)
60
+ assert_respond_to(@table, :background=)
61
+ end
62
+
63
+ def test_background
64
+ assert_nothing_raised{ @table.background }
65
+ assert_nil(@table.background)
66
+ assert_nothing_raised{ @table.background = 'foo' }
67
+ assert_equal('foo', @table.background)
68
+ end
69
+
70
+ def test_background_expected_errors
71
+ assert_raises(TypeError){ @table.background = 1 }
72
+ end
73
+
74
+ def test_bgcolor_basic
75
+ assert_respond_to(@table, :bgcolor)
76
+ assert_respond_to(@table, :bgcolor=)
77
+ end
78
+
79
+ def test_bgcolor
80
+ assert_nothing_raised{ @table.bgcolor }
81
+ assert_nil(@table.bgcolor)
82
+ assert_nothing_raised{ @table.bgcolor = 'foo' }
83
+ assert_equal('foo', @table.bgcolor)
84
+ end
85
+
86
+ def test_border_basic
87
+ assert_respond_to(@table, :border)
88
+ assert_respond_to(@table, :border=)
89
+ end
90
+
91
+ def test_border
92
+ assert_nothing_raised{ @table.border }
93
+ assert_nothing_raised{ @table.border = 2 }
94
+ assert_nothing_raised{ @table.border = true }
95
+ assert_nothing_raised{ @table.border = false }
96
+ end
97
+
98
+ def test_bordercolor_basic
99
+ assert_respond_to(@table, :bordercolor)
100
+ assert_respond_to(@table, :bordercolor=)
101
+ end
102
+
103
+ def test_bordercolor
104
+ assert_nothing_raised{ @table.bordercolor }
105
+ assert_nil(@table.bordercolor)
106
+ assert_nothing_raised{ @table.bordercolor = 'foo' }
107
+ assert_equal('foo', @table.bordercolor)
108
+ end
109
+
110
+ def test_bordercolordark_basic
111
+ assert_respond_to(@table, :bordercolordark)
112
+ assert_respond_to(@table, :bordercolordark=)
113
+ end
114
+
115
+ def test_bordercolordark
116
+ assert_nothing_raised{ @table.bordercolordark }
117
+ assert_nil(@table.bordercolordark)
118
+ assert_nothing_raised{ @table.bordercolordark = 'foo' }
119
+ assert_equal('foo', @table.bordercolordark)
120
+ end
121
+
122
+ def test_bordercolorlight
123
+ assert_respond_to(@table, :bordercolorlight)
124
+ assert_respond_to(@table, :bordercolorlight=)
125
+ assert_nothing_raised{ @table.bordercolorlight }
126
+ assert_nothing_raised{ @table.bordercolorlight = 'foo' }
127
+ end
128
+
129
+ def test_cellpadding
130
+ assert_respond_to(@table, :cellpadding)
131
+ assert_respond_to(@table, :cellpadding=)
132
+ assert_nothing_raised{ @table.cellpadding }
133
+ assert_nothing_raised{ @table.cellpadding = 1 }
134
+ end
135
+
136
+ def test_cellpadding_expected_errors
137
+ assert_raises(ArgumentError){ @table.cellpadding = -1 }
138
+ end
139
+
140
+ def test_cellspacing
141
+ assert_respond_to(@table, :cellspacing)
142
+ assert_respond_to(@table, :cellspacing=)
143
+ assert_nothing_raised{ @table.cellspacing }
144
+ assert_nothing_raised{ @table.cellspacing = 1 }
145
+ end
146
+
147
+ def test_cellspacing_expected_errors
148
+ assert_raises(ArgumentError){ @table.cellspacing = -1 }
149
+ end
150
+
151
+ def test_char
152
+ assert_respond_to(@table, :char)
153
+ assert_respond_to(@table, :char=)
154
+ assert_nothing_raised{ @table.char }
155
+ assert_nothing_raised{ @table.char = 'x' }
156
+ end
157
+
158
+ def test_char_expected_errors
159
+ assert_raises(ArgumentError){ @table.char = 'xx' }
160
+ end
161
+
162
+ def test_charoff
163
+ assert_respond_to(@table, :charoff)
164
+ assert_respond_to(@table, :charoff=)
165
+ assert_nothing_raised{ @table.charoff }
166
+ assert_nothing_raised{ @table.charoff = 1 }
167
+ end
168
+
169
+ def test_charoff_expected_errors
170
+ assert_raises(ArgumentError){ @table.charoff = -1 }
171
+ end
172
+
173
+ def test_class
174
+ assert_respond_to(@table, :class_)
175
+ assert_respond_to(@table, :class_=)
176
+ assert_nothing_raised{ @table.class_ }
177
+ assert_nothing_raised{ @table.class_ = 'myclass' }
178
+ end
179
+
180
+ def test_col
181
+ assert_respond_to(@table, :col)
182
+ assert_respond_to(@table, :col=)
183
+ assert_nothing_raised{ @table.col }
184
+ assert_nothing_raised{ @table.col = 1 }
185
+ end
186
+
187
+ def test_col_expected_errors
188
+ assert_raises(ArgumentError){ @table.col = -1 }
189
+ end
190
+
191
+ def test_colspan
192
+ assert_respond_to(@table, :colspan)
193
+ assert_respond_to(@table, :colspan=)
194
+ assert_nothing_raised{ @table.colspan }
195
+ assert_nothing_raised{ @table.colspan = 1 }
196
+ end
197
+
198
+ def test_colspan_expected_errors
199
+ assert_raises(ArgumentError){ @table.colspan = -1 }
200
+ end
201
+
202
+ def test_configure
203
+ assert_respond_to(@table, :configure)
204
+ assert_nothing_raised{ @table.configure(0){} }
205
+ assert_nothing_raised{ @table.configure(0,0){} }
206
+ end
207
+
208
+ def test_configure_expected_errors
209
+ assert_raises(ArgumentError){ @table.configure(0,0,0){} }
210
+ end
211
+
212
+ ########################################################################
213
+ # This test could probably be broken out into separate tests for each
214
+ # type that we want to add as content.
215
+ ########################################################################
216
+ def test_content
217
+ assert_respond_to(@table, :content)
218
+ assert_respond_to(@table, :content=)
219
+ assert_nothing_raised{ @table.content = 'foo' }
220
+ assert_nothing_raised{ @table.content = 123 }
221
+ assert_nothing_raised{ @table.content = ['one',2,'three'] }
222
+ assert_nothing_raised{ @table.content = [['foo','bar'],[1,2,3]] }
223
+ assert_nothing_raised{ @table.content = Table::Row.new }
224
+ assert_nothing_raised{ @table.content = Table::Row::Data.new }
225
+ assert_nothing_raised{ @table.content = Table::Row::Header.new }
226
+ assert_nothing_raised{ @table.content = Table::Head.create }
227
+ assert_nothing_raised{ @table.content = Table::Foot.create }
228
+ assert_nothing_raised{ @table.content = Table::Body.new }
229
+ end
230
+
231
+ def test_frame
232
+ assert_respond_to(@table, :frame)
233
+ assert_respond_to(@table, :frame=)
234
+ assert_nothing_raised{ @table.frame }
235
+ assert_nothing_raised{ @table.frame = 'below' }
236
+ end
237
+
238
+ def test_frame_expected_errors
239
+ assert_raises(ArgumentError){ @table.frame = 'foo' }
240
+ end
241
+
242
+ def test_height
243
+ assert_respond_to(@table, :height)
244
+ assert_respond_to(@table, :height=)
245
+ assert_nothing_raised{ @table.height }
246
+ assert_nothing_raised{ @table.height = 1 }
247
+ end
248
+
249
+ def test_height_expected_errors
250
+ assert_raises(ArgumentError){ @table.height = -1 }
251
+ end
252
+
253
+ def test_hspace
254
+ assert_respond_to(@table, :hspace)
255
+ assert_respond_to(@table, :hspace=)
256
+ assert_nothing_raised{ @table.hspace }
257
+ assert_nothing_raised{ @table.hspace = 1 }
258
+ end
259
+
260
+ def test_hspace_expected_errors
261
+ assert_raises(ArgumentError){ @table.hspace = -1 }
262
+ end
263
+
264
+ def test_nowrap
265
+ assert_respond_to(@table, :nowrap)
266
+ assert_respond_to(@table, :nowrap=)
267
+ assert_nothing_raised{ @table.nowrap }
268
+ assert_nothing_raised{ @table.nowrap = false }
269
+ end
270
+
271
+ def test_nowrap_expected_errors
272
+ assert_raises(TypeError){ @table.nowrap = 'foo' }
273
+ end
274
+
275
+ def test_rowspan
276
+ assert_respond_to(@table, :rowspan)
277
+ assert_respond_to(@table, :rowspan=)
278
+ assert_nothing_raised{ @table.rowspan }
279
+ assert_nothing_raised{ @table.rowspan = 1 }
280
+ end
281
+
282
+ def test_rowspan_expected_errors
283
+ assert_raises(ArgumentError){ @table.rowspan = -1 }
284
+ end
285
+
286
+ def test_rules
287
+ assert_respond_to(@table, :rules)
288
+ assert_respond_to(@table, :rules=)
289
+ assert_nothing_raised{ @table.rules }
290
+ assert_nothing_raised{ @table.rules = 'all' }
291
+ end
292
+
293
+ def test_rules_expected_errors
294
+ assert_raises(ArgumentError){ @table.rules = 'foo' }
295
+ end
296
+
297
+ def test_span
298
+ assert_respond_to(@table, :span)
299
+ assert_respond_to(@table, :span=)
300
+ assert_nothing_raised{ @table.span }
301
+ assert_nothing_raised{ @table.span = 1 }
302
+ end
303
+
304
+ def test_span_expected_errors
305
+ assert_raises(ArgumentError){ @table.span = -1 }
306
+ end
307
+
308
+ def test_style
309
+ assert_respond_to(@table, :style)
310
+ assert_respond_to(@table, :style=)
311
+ assert_nothing_raised{ @table.style }
312
+ assert_nothing_raised{ @table.style = 'color: blue' }
313
+ end
314
+
315
+ def test_summary
316
+ assert_respond_to(@table, :summary)
317
+ assert_respond_to(@table, :summary=)
318
+ assert_nothing_raised{ @table.summary }
319
+ assert_nothing_raised{ @table.summary = 'foo' }
320
+ assert_nothing_raised{ @table.summary = 1 }
321
+ end
322
+
323
+ def test_valign
324
+ assert_respond_to(@table, :valign)
325
+ assert_respond_to(@table, :valign=)
326
+ assert_nothing_raised{ @table.valign }
327
+ assert_nothing_raised{ @table.valign = 'center' }
328
+ end
329
+
330
+ def test_valign_expected_errors
331
+ assert_raises(ArgumentError){ @table.valign = 'foo' }
332
+ end
333
+
334
+ def test_vspace
335
+ assert_respond_to(@table, :vspace)
336
+ assert_respond_to(@table, :vspace=)
337
+ assert_nothing_raised{ @table.vspace }
338
+ assert_nothing_raised{ @table.vspace = 1 }
339
+ end
340
+
341
+ def test_vspace_expected_errors
342
+ assert_raises(ArgumentError){ @table.vspace = -1 }
343
+ end
344
+
345
+ def test_width
346
+ assert_respond_to(@table, :width)
347
+ assert_respond_to(@table, :width=)
348
+ assert_nothing_raised{ @table.width}
349
+ assert_nothing_raised{ @table.width = 10 }
350
+ assert_nothing_raised{ @table.width = '5%' }
351
+ end
352
+
353
+ def test_width_expected_errors
354
+ assert_raises(ArgumentError){ @table.width = -1 }
355
+ end
356
+
357
+ def teardown
358
+ @table = nil
359
+ end
360
+
361
+ def self.shutdown
362
+ NonStandardExtensionWarning.enable
363
+ end
364
+ end