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.
@@ -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
- end
45
- 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,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
- 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
- @table = Table.new(['foo',1,'bar'])
24
- end
25
-
26
- def test_abbr
27
- assert_respond_to(@table, :abbr)
28
- assert_respond_to(@table, :abbr=)
29
- assert_nothing_raised{ @table.abbr }
30
- assert_nothing_raised{ @table.abbr = 'foo' }
31
- end
32
-
33
- def test_align
34
- assert_respond_to(@table, :align)
35
- assert_respond_to(@table, :align=)
36
- assert_nothing_raised{ @table.align }
37
- assert_nothing_raised{ @table.align = 'center' }
38
- assert_raises(ArgumentError){ @table.align = 'foo' }
39
- end
40
-
41
- def test_axis
42
- assert_respond_to(@table, :axis)
43
- assert_respond_to(@table, :axis=)
44
- assert_nothing_raised{ @table.axis }
45
- assert_nothing_raised{ @table.axis = 'foo' }
46
- end
47
-
48
- def test_background
49
- assert_respond_to(@table, :background)
50
- assert_respond_to(@table, :background=)
51
- assert_nothing_raised{ @table.background }
52
- assert_nothing_raised{ @table.background = 'foo' }
53
- assert_raises(TypeError){ @table.background = 1 }
54
- end
55
-
56
- def test_bgcolor
57
- assert_respond_to(@table, :bgcolor)
58
- assert_respond_to(@table, :bgcolor=)
59
- assert_nothing_raised{ @table.bgcolor }
60
- assert_nothing_raised{ @table.bgcolor = 'foo' }
61
- end
62
-
63
- def test_border
64
- assert_respond_to(@table, :border)
65
- assert_respond_to(@table, :border=)
66
- assert_nothing_raised{ @table.border }
67
- assert_nothing_raised{ @table.border = 2 }
68
- assert_nothing_raised{ @table.border = true }
69
- assert_nothing_raised{ @table.border = false }
70
- end
71
-
72
- def test_bordercolor
73
- assert_respond_to(@table, :bordercolor)
74
- assert_respond_to(@table, :bordercolor=)
75
- assert_nothing_raised{ @table.bordercolor }
76
- assert_nothing_raised{ @table.bordercolor = 'foo' }
77
- end
78
-
79
- def test_bordercolordark
80
- assert_respond_to(@table, :bordercolordark)
81
- assert_respond_to(@table, :bordercolordark=)
82
- assert_nothing_raised{ @table.bordercolordark }
83
- assert_nothing_raised{ @table.bordercolordark = 'foo' }
84
- end
85
-
86
- def test_bordercolorlight
87
- assert_respond_to(@table, :bordercolorlight)
88
- assert_respond_to(@table, :bordercolorlight=)
89
- assert_nothing_raised{ @table.bordercolorlight }
90
- assert_nothing_raised{ @table.bordercolorlight = 'foo' }
91
- end
92
-
93
- def test_cellpadding
94
- assert_respond_to(@table, :cellpadding)
95
- assert_respond_to(@table, :cellpadding=)
96
- assert_nothing_raised{ @table.cellpadding }
97
- assert_nothing_raised{ @table.cellpadding = 1 }
98
- assert_raises(ArgumentError){ @table.cellpadding = -1 }
99
- end
100
-
101
- def test_cellspacing
102
- assert_respond_to(@table, :cellspacing)
103
- assert_respond_to(@table, :cellspacing=)
104
- assert_nothing_raised{ @table.cellspacing }
105
- assert_nothing_raised{ @table.cellspacing = 1 }
106
- assert_raises(ArgumentError){ @table.cellspacing = -1 }
107
- end
108
-
109
- def test_char
110
- assert_respond_to(@table, :char)
111
- assert_respond_to(@table, :char=)
112
- assert_nothing_raised{ @table.char }
113
- assert_nothing_raised{ @table.char = 'x' }
114
- assert_raises(ArgumentError){ @table.char = 'xx' }
115
- end
116
-
117
- def test_charoff
118
- assert_respond_to(@table, :charoff)
119
- assert_respond_to(@table, :charoff=)
120
- assert_nothing_raised{ @table.charoff }
121
- assert_nothing_raised{ @table.charoff = 1 }
122
- assert_raises(ArgumentError){ @table.charoff = -1 }
123
- end
124
-
125
- def test_class
126
- assert_respond_to(@table, :class_)
127
- assert_respond_to(@table, :class_=)
128
- assert_nothing_raised{ @table.class_ }
129
- assert_nothing_raised{ @table.class_ = 'myclass' }
130
- end
131
-
132
- def test_col
133
- assert_respond_to(@table, :col)
134
- assert_respond_to(@table, :col=)
135
- assert_nothing_raised{ @table.col }
136
- assert_nothing_raised{ @table.col = 1 }
137
- assert_raises(ArgumentError){ @table.col = -1 }
138
- end
139
-
140
- def test_colspan
141
- assert_respond_to(@table, :colspan)
142
- assert_respond_to(@table, :colspan=)
143
- assert_nothing_raised{ @table.colspan }
144
- assert_nothing_raised{ @table.colspan = 1 }
145
- assert_raises(ArgumentError){ @table.colspan = -1 }
146
- end
147
-
148
- def test_configure
149
- assert_respond_to(@table, :configure)
150
- assert_nothing_raised{ @table.configure(0){} }
151
- assert_nothing_raised{ @table.configure(0,0){} }
152
- assert_raises(ArgumentError){ @table.configure(0,0,0){} }
153
- end
154
-
155
- ########################################################################
156
- # This test could probably be broken out into separate tests for each
157
- # type that we want to add as content.
158
- ########################################################################
159
- def test_content
160
- assert_respond_to(@table, :content)
161
- assert_respond_to(@table, :content=)
162
- assert_nothing_raised{ @table.content = 'foo' }
163
- assert_nothing_raised{ @table.content = 123 }
164
- assert_nothing_raised{ @table.content = ['one',2,'three'] }
165
- assert_nothing_raised{ @table.content = [['foo','bar'],[1,2,3]] }
166
- assert_nothing_raised{ @table.content = Table::Row.new }
167
- assert_nothing_raised{ @table.content = Table::Row::Data.new }
168
- assert_nothing_raised{ @table.content = Table::Row::Header.new }
169
- assert_nothing_raised{ @table.content = Table::Head.create }
170
- assert_nothing_raised{ @table.content = Table::Foot.create }
171
- assert_nothing_raised{ @table.content = Table::Body.new }
172
- end
173
-
174
- def test_frame
175
- assert_respond_to(@table, :frame)
176
- assert_respond_to(@table, :frame=)
177
- assert_nothing_raised{ @table.frame }
178
- assert_nothing_raised{ @table.frame = 'below' }
179
- assert_raises(ArgumentError){ @table.frame = 'foo' }
180
- end
181
-
182
- def test_height
183
- assert_respond_to(@table, :height)
184
- assert_respond_to(@table, :height=)
185
- assert_nothing_raised{ @table.height }
186
- assert_nothing_raised{ @table.height = 1 }
187
- assert_raises(ArgumentError){ @table.height = -1 }
188
- end
189
-
190
- def test_hspace
191
- assert_respond_to(@table, :hspace)
192
- assert_respond_to(@table, :hspace=)
193
- assert_nothing_raised{ @table.hspace }
194
- assert_nothing_raised{ @table.hspace = 1 }
195
- assert_raises(ArgumentError){ @table.hspace = -1 }
196
- end
197
-
198
- def test_nowrap
199
- assert_respond_to(@table, :nowrap)
200
- assert_respond_to(@table, :nowrap=)
201
- assert_nothing_raised{ @table.nowrap }
202
- assert_nothing_raised{ @table.nowrap = false }
203
- assert_raises(TypeError){ @table.nowrap = 'foo' }
204
- end
205
-
206
- def test_rowspan
207
- assert_respond_to(@table, :rowspan)
208
- assert_respond_to(@table, :rowspan=)
209
- assert_nothing_raised{ @table.rowspan }
210
- assert_nothing_raised{ @table.rowspan = 1 }
211
- assert_raises(ArgumentError){ @table.rowspan = -1 }
212
- end
213
-
214
- def test_rules
215
- assert_respond_to(@table, :rules)
216
- assert_respond_to(@table, :rules=)
217
- assert_nothing_raised{ @table.rules }
218
- assert_nothing_raised{ @table.rules = 'all' }
219
- assert_raises(ArgumentError){ @table.rules = 'foo' }
220
- end
221
-
222
- def test_span
223
- assert_respond_to(@table, :span)
224
- assert_respond_to(@table, :span=)
225
- assert_nothing_raised{ @table.span }
226
- assert_nothing_raised{ @table.span = 1 }
227
- assert_raises(ArgumentError){ @table.span = -1 }
228
- end
229
-
230
- def test_style
231
- assert_respond_to(@table, :style)
232
- assert_respond_to(@table, :style=)
233
- assert_nothing_raised{ @table.style }
234
- assert_nothing_raised{ @table.style = 'color: blue' }
235
- end
236
-
237
- def test_summary
238
- assert_respond_to(@table, :summary)
239
- assert_respond_to(@table, :summary=)
240
- assert_nothing_raised{ @table.summary }
241
- assert_nothing_raised{ @table.summary = 'foo' }
242
- assert_nothing_raised{ @table.summary = 1 }
243
- end
244
-
245
- def test_valign
246
- assert_respond_to(@table, :valign)
247
- assert_respond_to(@table, :valign=)
248
- assert_nothing_raised{ @table.valign }
249
- assert_nothing_raised{ @table.valign = 'center' }
250
- assert_raises(ArgumentError){ @table.valign = 'foo' }
251
- end
252
-
253
- def test_vspace
254
- assert_respond_to(@table, :vspace)
255
- assert_respond_to(@table, :vspace=)
256
- assert_nothing_raised{ @table.vspace }
257
- assert_nothing_raised{ @table.vspace = 1 }
258
- assert_raises(ArgumentError){ @table.vspace = -1 }
259
- end
260
-
261
- def test_width
262
- assert_respond_to(@table, :width)
263
- assert_respond_to(@table, :width=)
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