html-table 1.6.3 → 1.7.1

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.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/{CHANGES.rdoc → CHANGES.md} +76 -68
  4. data/Gemfile +2 -0
  5. data/MANIFEST.md +57 -0
  6. data/{README.rdoc → README.md} +80 -71
  7. data/Rakefile +122 -146
  8. data/doc/attributes.md +160 -0
  9. data/doc/table.md +173 -0
  10. data/doc/table_body.md +9 -0
  11. data/doc/table_caption.md +10 -0
  12. data/doc/table_colgroup.md +8 -0
  13. data/doc/table_colgroup_col.md +7 -0
  14. data/doc/table_content.md +17 -0
  15. data/doc/table_foot.md +8 -0
  16. data/doc/table_head.md +10 -0
  17. data/doc/table_row.md +114 -0
  18. data/doc/table_row_data.md +100 -0
  19. data/doc/table_row_header.md +6 -0
  20. data/examples/simple1.rb +7 -5
  21. data/html-table.gemspec +16 -11
  22. data/lib/html/body.rb +9 -7
  23. data/lib/html/caption.rb +4 -2
  24. data/lib/html/col.rb +37 -34
  25. data/lib/html/colgroup.rb +90 -97
  26. data/lib/html/content.rb +3 -6
  27. data/lib/html/data.rb +3 -1
  28. data/lib/html/foot.rb +53 -45
  29. data/lib/html/head.rb +54 -47
  30. data/lib/html/header.rb +5 -3
  31. data/lib/html/mixin/attribute_handler.rb +59 -55
  32. data/lib/html/mixin/html_handler.rb +33 -35
  33. data/lib/html/mixin/strongtyping.rb +6 -6
  34. data/lib/html/mixin/tag_handler.rb +6 -2
  35. data/lib/html/row.rb +156 -183
  36. data/lib/html/table.rb +45 -45
  37. data/lib/html/tablesection.rb +51 -46
  38. data/spec/attribute_handler_spec.rb +374 -0
  39. data/spec/body_spec.rb +98 -0
  40. data/spec/caption_spec.rb +83 -0
  41. data/spec/colgroup_col_spec.rb +34 -0
  42. data/spec/colgroup_spec.rb +97 -0
  43. data/spec/data_spec.rb +88 -0
  44. data/spec/foot_spec.rb +116 -0
  45. data/spec/head_spec.rb +116 -0
  46. data/spec/header_spec.rb +85 -0
  47. data/spec/html_handler_spec.rb +35 -0
  48. data/spec/row_spec.rb +163 -0
  49. data/spec/table_spec.rb +186 -0
  50. data/spec/tablesection_spec.rb +36 -0
  51. data/spec/tag_handler_spec.rb +85 -0
  52. data.tar.gz.sig +0 -0
  53. metadata +118 -92
  54. metadata.gz.sig +0 -0
  55. data/MANIFEST.rdoc +0 -56
  56. data/doc/attributes.rdoc +0 -143
  57. data/doc/table.rdoc +0 -156
  58. data/doc/table_body.rdoc +0 -9
  59. data/doc/table_caption.rdoc +0 -9
  60. data/doc/table_colgroup.rdoc +0 -8
  61. data/doc/table_colgroup_col.rdoc +0 -9
  62. data/doc/table_content.rdoc +0 -15
  63. data/doc/table_foot.rdoc +0 -8
  64. data/doc/table_head.rdoc +0 -11
  65. data/doc/table_row.rdoc +0 -105
  66. data/doc/table_row_data.rdoc +0 -92
  67. data/doc/table_row_header.rdoc +0 -7
  68. data/test/test_attribute_handler.rb +0 -361
  69. data/test/test_body.rb +0 -87
  70. data/test/test_caption.rb +0 -80
  71. data/test/test_col.rb +0 -40
  72. data/test/test_colgroup.rb +0 -89
  73. data/test/test_data.rb +0 -77
  74. data/test/test_foot.rb +0 -111
  75. data/test/test_head.rb +0 -104
  76. data/test/test_header.rb +0 -77
  77. data/test/test_html_handler.rb +0 -37
  78. data/test/test_row.rb +0 -141
  79. data/test/test_table.rb +0 -159
  80. data/test/test_tablesection.rb +0 -42
  81. data/test/test_tag_handler.rb +0 -90
@@ -1,15 +0,0 @@
1
- == Description
2
- A Table::Content is a wrapper for content used for Table::Row::Data and
3
- Table::Row::Header objects. Although it can be instantiated directly, in
4
- practice it is autogenerated for you.
5
-
6
- == Notes
7
- Table::Content is a subclass of String and was mostly created in order
8
- to support a DSL style syntax as well as physical tags.
9
-
10
- == Synopsis
11
- content = Table::Content.new('my content') do
12
- bold true
13
- italics true
14
- underline true
15
- end
data/doc/table_foot.rdoc DELETED
@@ -1,8 +0,0 @@
1
- == Description
2
- A Table::Foot object represents a single <TFOOT></TFOOT> instance for an
3
- HTML Table.
4
- == Notes
5
- In virtually every respect the Table::Foot class is identical to
6
- the Table or Table::Row class. There is one significant difference.
7
- The Table::Foot class is a singleton. There can be only one
8
- Table::Foot instance per table.
data/doc/table_head.rdoc DELETED
@@ -1,11 +0,0 @@
1
- == Description
2
- A Table::Head object represents a single <THEAD></THEAD> instance for an
3
- HTML Table.
4
-
5
- == Notes
6
- In virtually every respect the Table::Head class is identical to
7
- the Table or Table::Row class. There are two significant differences.
8
- First, the Table::Head class is a singleton. There can be only one
9
- Table::Head instance per table. Second, if an instance of Table::Head
10
- is added to a table, it will be automatically be put at index 0 (or 1
11
- if a Table::Caption exists).
data/doc/table_row.rdoc DELETED
@@ -1,105 +0,0 @@
1
- = Description
2
- A Table::Row object represents a single <TR></TR> instance for an HTML
3
- Table. Although it is nested under Table, it is not a subclass of Table.
4
- It is, however, a subclass of Array.
5
-
6
- == Synopsis
7
- require "html/table"
8
- include HTML
9
-
10
- table = HTML::Table.new
11
-
12
- row1 = Table::Row.new{ |r|
13
- r.align = "left"
14
- r.bgcolor = "green"
15
- r.content = ["foo","bar","baz"]
16
- }
17
-
18
- row2 = Table::Row.new{ |r|
19
- r.align = "right"
20
- r.bgcolor = "blue"
21
- r.content = "hello world"
22
- }
23
-
24
- table.push row1, row2
25
-
26
- row1.content = "foofoo"
27
- row1.configure(3){ |d| d.bgcolor = "pink" }
28
-
29
- row1.push Table::Row::Header.new{ |h|
30
- h.colspan = 2
31
- h.content = "This is a table header"
32
- }
33
-
34
- row2.push Table::Row::Header.new{ |h|
35
- h.colspan = 2
36
- h.content = "This is also a table header"
37
- }
38
-
39
- puts table.html
40
-
41
- #### output ####
42
- <table>
43
- <tr align='left' bgcolor='green'>
44
- <td>foo</td>
45
- <td>bar</td>
46
- <td>baz</td>
47
- <td bgcolor='pink'>foofoo</td>
48
- <th colspan=2>This is a table header</th>
49
- </tr>
50
- <tr align='right' bgcolor='blue'>
51
- <td>hello world</td>
52
- <th colspan=2>This is also a table header</th>
53
- </tr>
54
- </table>
55
-
56
- See the 'examples' directory for more examples.
57
-
58
- == Mixins
59
- Table::Row is a subclass of Array and therefore mixes in Enumerable. It
60
- also mixes in Attribute_Handler.
61
-
62
- == Class Methods
63
- Table::Row.new(arg=nil)
64
- Table::Row.new(arg=nil){ |t| ... }
65
- Creates a new table. You can set attributes for the TableRow by passing
66
- a block.
67
-
68
- If +arg+ is supplied, it is automatically interpreted to be content.
69
- This is a shortcut for Table::Row.new{ |r| r.content = '...' }.
70
-
71
- == Instance Methods
72
- Table::Row#[]=(index,obj)
73
- Assigns +obj+ to index. The +obj+ must be a Table::Row::Header or
74
- Table::Row::Data object, or a TypeError is raised.
75
-
76
- Table::Row#content
77
- Returns the HTML content of the TableRow instance, i.e. the stuff between
78
- the <TR> and </TR> tags.
79
-
80
- Table::Row#content=(args)
81
- Because a Table::Row doesn't store any of its own content, the arguments
82
- to this method must be a Table::Row::Data object, a Table::Row::Header
83
- object, or a String (or an array of any of these). In the latter case,
84
- a single Table::Row::Data object is created for each string.
85
-
86
- Table::Row#html
87
- Returns the entire HTML content of the TableRow instance.
88
-
89
- Table::Row#push(obj)
90
- Pushes +obj+ onto the Table::Row. The +obj+ must be a
91
- Table::Row::Data or Table::Row::Header object, or a TypeError is
92
- raised.
93
-
94
- Table::Row#unshift(obj)
95
- Unshifts +obj+ onto the Table::Row. The same rules for push apply
96
- to unshift as well.
97
-
98
- == Notes
99
- String attributes are quoted. Numeric attributes are not.
100
-
101
- Some attributes have type checking. Some check for valid arguments. In
102
- the latter case, it is case-insensitive.
103
-
104
- Using a non-standard extension (e.g. "background") will send a warning to
105
- STDERR in $VERBOSE (-w) mode.
@@ -1,92 +0,0 @@
1
- == Description
2
- A Table::Row::Data object represents a single <TD></TD> instance for an HTML
3
- Table. For purposes of html-table, it also represents a "column"
4
-
5
- == Synopsis
6
- require "html/table"
7
- require HTML
8
-
9
- Table::Row.end_tags = false
10
- Table::Row::Data.end_tags = false
11
-
12
- table = Table.new{ |t| t.border = 1 }
13
- row = Table::Row.new
14
-
15
- col1 = Table::Row::Data.new{ |d|
16
- d.abbr = "test"
17
- d.align = "right"
18
- d.content = "hello world"
19
- }
20
-
21
- col2 = Table::Row::Data.new{ |d|
22
- d.align = "center"
23
- d.content = "Matz rules!"
24
- }
25
-
26
- col3 = Table::Row::Data.new{ |d|
27
- d.align = "left"
28
- d.content = "Foo!"
29
- }
30
-
31
- row.push col1, col2, col3
32
-
33
- puts table.html
34
-
35
- #### output ####
36
- <table border=1>
37
- <tr>
38
- <td abbr='test' align='right'>hello world
39
- <td align='center'>Matz rules!
40
- <td align='left'>Foo!
41
- </table>
42
-
43
- See the 'examples' directory under 'doc' for more examples.
44
-
45
- == Mixins
46
- Table::Row::Data mixes in Attribute_Handler.
47
-
48
- == Class Methods
49
- Table::Row::Data.new(arg=nil)
50
- Table::Row::Data.new(arg=nil){ |t| ... }
51
- Creates a new table. You can set attributes for the Table::Row::Data by
52
- passing a block.
53
-
54
- If +arg+ is supplied, it is automatically interpreted to be content.
55
- This is a shortcut for Table::Row::Data.new{ |d| d.content = '...' }.
56
-
57
- Table::Row::Data.end_tags
58
- Returns true or false to indicate whether end tags are included or not.
59
-
60
- Table::Row::Data.end_tags=(bool)
61
- Sets whether or not end tags are included in the html.
62
-
63
- Table::Row::Data.indent_level
64
- Returns the current number of spaces that <TD> tags are indented. The
65
- default is 6.
66
-
67
- Table::Row::Data.indent_level=(num)
68
- Sets the number of spaces that <TD> tags are indented.
69
-
70
- == Instance Methods
71
- TableData#content
72
- Returns the content of the TableData object, i.e. the stuff between <TD>
73
- and </TD>.
74
-
75
- Table::Row::Data#content=(string)
76
- Sets the content for the TableData object, i.e. the stuff between <TD>
77
- and </TD>.
78
-
79
- Table::Row::Data#html
80
- Returns all html content for the TableData instance.
81
-
82
- == Notes
83
- The end tags for Table::Row::Data objects are are the same line as the
84
- begin tags.
85
-
86
- String attributes are quoted. Numeric attributes are not.
87
-
88
- Some attributes have type checking. Some check for valid arguments. In
89
- the latter case, it is case-insensitive.
90
-
91
- Using a non-standard extension (e.g. "background") will send a warning to
92
- STDERR in $VERBOSE (-w) mode.
@@ -1,7 +0,0 @@
1
- == Description
2
- A Table::Row::Header object represents a single <TH></TH> instance for
3
- an HTML Table.
4
-
5
- == Notes
6
- The Table::Row::Header class is identical in every way to the
7
- Table::Row::Data class, except for the begin and end tags.
@@ -1,361 +0,0 @@
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 'test-unit'
8
- require 'html/table'
9
- include HTML
10
-
11
- class TC_AttributeHandler < Test::Unit::TestCase
12
- def self.startup
13
- NonStandardExtensionWarning.disable
14
- end
15
-
16
- def setup
17
- @table = Table.new(['foo',1,'bar'])
18
- end
19
-
20
- def test_abbr_basic
21
- assert_respond_to(@table, :abbr)
22
- assert_respond_to(@table, :abbr=)
23
- end
24
-
25
- def test_abbr
26
- assert_nothing_raised{ @table.abbr }
27
- assert_nil(@table.abbr)
28
- assert_nothing_raised{ @table.abbr = 'foo' }
29
- assert_equal('foo', @table.abbr)
30
- end
31
-
32
- def test_align_basic
33
- assert_respond_to(@table, :align)
34
- assert_respond_to(@table, :align=)
35
- end
36
-
37
- def test_align
38
- assert_nothing_raised{ @table.align }
39
- assert_nil(@table.align)
40
- assert_nothing_raised{ @table.align = 'center' }
41
- assert_equal('center', @table.align)
42
- end
43
-
44
- def test_align_expected_errors
45
- assert_raises(ArgumentError){ @table.align = 'foo' }
46
- end
47
-
48
- def test_axis
49
- assert_respond_to(@table, :axis)
50
- assert_respond_to(@table, :axis=)
51
- assert_nothing_raised{ @table.axis }
52
- assert_nothing_raised{ @table.axis = 'foo' }
53
- end
54
-
55
- def test_background_basic
56
- assert_respond_to(@table, :background)
57
- assert_respond_to(@table, :background=)
58
- end
59
-
60
- def test_background
61
- assert_nothing_raised{ @table.background }
62
- assert_nil(@table.background)
63
- assert_nothing_raised{ @table.background = 'foo' }
64
- assert_equal('foo', @table.background)
65
- end
66
-
67
- def test_background_expected_errors
68
- assert_raises(TypeError){ @table.background = 1 }
69
- end
70
-
71
- def test_bgcolor_basic
72
- assert_respond_to(@table, :bgcolor)
73
- assert_respond_to(@table, :bgcolor=)
74
- end
75
-
76
- def test_bgcolor
77
- assert_nothing_raised{ @table.bgcolor }
78
- assert_nil(@table.bgcolor)
79
- assert_nothing_raised{ @table.bgcolor = 'foo' }
80
- assert_equal('foo', @table.bgcolor)
81
- end
82
-
83
- def test_border_basic
84
- assert_respond_to(@table, :border)
85
- assert_respond_to(@table, :border=)
86
- end
87
-
88
- def test_border
89
- assert_nothing_raised{ @table.border }
90
- assert_nothing_raised{ @table.border = 2 }
91
- assert_nothing_raised{ @table.border = true }
92
- assert_nothing_raised{ @table.border = false }
93
- end
94
-
95
- def test_bordercolor_basic
96
- assert_respond_to(@table, :bordercolor)
97
- assert_respond_to(@table, :bordercolor=)
98
- end
99
-
100
- def test_bordercolor
101
- assert_nothing_raised{ @table.bordercolor }
102
- assert_nil(@table.bordercolor)
103
- assert_nothing_raised{ @table.bordercolor = 'foo' }
104
- assert_equal('foo', @table.bordercolor)
105
- end
106
-
107
- def test_bordercolordark_basic
108
- assert_respond_to(@table, :bordercolordark)
109
- assert_respond_to(@table, :bordercolordark=)
110
- end
111
-
112
- def test_bordercolordark
113
- assert_nothing_raised{ @table.bordercolordark }
114
- assert_nil(@table.bordercolordark)
115
- assert_nothing_raised{ @table.bordercolordark = 'foo' }
116
- assert_equal('foo', @table.bordercolordark)
117
- end
118
-
119
- def test_bordercolorlight
120
- assert_respond_to(@table, :bordercolorlight)
121
- assert_respond_to(@table, :bordercolorlight=)
122
- assert_nothing_raised{ @table.bordercolorlight }
123
- assert_nothing_raised{ @table.bordercolorlight = 'foo' }
124
- end
125
-
126
- def test_cellpadding
127
- assert_respond_to(@table, :cellpadding)
128
- assert_respond_to(@table, :cellpadding=)
129
- assert_nothing_raised{ @table.cellpadding }
130
- assert_nothing_raised{ @table.cellpadding = 1 }
131
- end
132
-
133
- def test_cellpadding_expected_errors
134
- assert_raises(ArgumentError){ @table.cellpadding = -1 }
135
- end
136
-
137
- def test_cellspacing
138
- assert_respond_to(@table, :cellspacing)
139
- assert_respond_to(@table, :cellspacing=)
140
- assert_nothing_raised{ @table.cellspacing }
141
- assert_nothing_raised{ @table.cellspacing = 1 }
142
- end
143
-
144
- def test_cellspacing_expected_errors
145
- assert_raises(ArgumentError){ @table.cellspacing = -1 }
146
- end
147
-
148
- def test_char
149
- assert_respond_to(@table, :char)
150
- assert_respond_to(@table, :char=)
151
- assert_nothing_raised{ @table.char }
152
- assert_nothing_raised{ @table.char = 'x' }
153
- end
154
-
155
- def test_char_expected_errors
156
- assert_raises(ArgumentError){ @table.char = 'xx' }
157
- end
158
-
159
- def test_charoff
160
- assert_respond_to(@table, :charoff)
161
- assert_respond_to(@table, :charoff=)
162
- assert_nothing_raised{ @table.charoff }
163
- assert_nothing_raised{ @table.charoff = 1 }
164
- end
165
-
166
- def test_charoff_expected_errors
167
- assert_raises(ArgumentError){ @table.charoff = -1 }
168
- end
169
-
170
- def test_class
171
- assert_respond_to(@table, :class_)
172
- assert_respond_to(@table, :class_=)
173
- assert_nothing_raised{ @table.class_ }
174
- assert_nothing_raised{ @table.class_ = 'myclass' }
175
- end
176
-
177
- def test_col
178
- assert_respond_to(@table, :col)
179
- assert_respond_to(@table, :col=)
180
- assert_nothing_raised{ @table.col }
181
- assert_nothing_raised{ @table.col = 1 }
182
- end
183
-
184
- def test_col_expected_errors
185
- assert_raises(ArgumentError){ @table.col = -1 }
186
- end
187
-
188
- def test_colspan
189
- assert_respond_to(@table, :colspan)
190
- assert_respond_to(@table, :colspan=)
191
- assert_nothing_raised{ @table.colspan }
192
- assert_nothing_raised{ @table.colspan = 1 }
193
- end
194
-
195
- def test_colspan_expected_errors
196
- assert_raises(ArgumentError){ @table.colspan = -1 }
197
- end
198
-
199
- def test_configure
200
- assert_respond_to(@table, :configure)
201
- assert_nothing_raised{ @table.configure(0){} }
202
- assert_nothing_raised{ @table.configure(0,0){} }
203
- end
204
-
205
- def test_configure_expected_errors
206
- assert_raises(ArgumentError){ @table.configure(0,0,0){} }
207
- end
208
-
209
- ########################################################################
210
- # This test could probably be broken out into separate tests for each
211
- # type that we want to add as content.
212
- ########################################################################
213
- def test_content
214
- assert_respond_to(@table, :content)
215
- assert_respond_to(@table, :content=)
216
- assert_nothing_raised{ @table.content = 'foo' }
217
- assert_nothing_raised{ @table.content = 123 }
218
- assert_nothing_raised{ @table.content = ['one',2,'three'] }
219
- assert_nothing_raised{ @table.content = [['foo','bar'],[1,2,3]] }
220
- assert_nothing_raised{ @table.content = Table::Row.new }
221
- assert_nothing_raised{ @table.content = Table::Row::Data.new }
222
- assert_nothing_raised{ @table.content = Table::Row::Header.new }
223
- assert_nothing_raised{ @table.content = Table::Head.create }
224
- assert_nothing_raised{ @table.content = Table::Foot.create }
225
- assert_nothing_raised{ @table.content = Table::Body.new }
226
- end
227
-
228
- def test_frame
229
- assert_respond_to(@table, :frame)
230
- assert_respond_to(@table, :frame=)
231
- assert_nothing_raised{ @table.frame }
232
- assert_nothing_raised{ @table.frame = 'below' }
233
- end
234
-
235
- def test_frame_expected_errors
236
- assert_raises(ArgumentError){ @table.frame = 'foo' }
237
- end
238
-
239
- def test_height
240
- assert_respond_to(@table, :height)
241
- assert_respond_to(@table, :height=)
242
- assert_nothing_raised{ @table.height }
243
- assert_nothing_raised{ @table.height = 1 }
244
- end
245
-
246
- def test_height_expected_errors
247
- assert_raises(ArgumentError){ @table.height = -1 }
248
- end
249
-
250
- def test_hspace
251
- assert_respond_to(@table, :hspace)
252
- assert_respond_to(@table, :hspace=)
253
- assert_nothing_raised{ @table.hspace }
254
- assert_nothing_raised{ @table.hspace = 1 }
255
- end
256
-
257
- def test_hspace_expected_errors
258
- assert_raises(ArgumentError){ @table.hspace = -1 }
259
- end
260
-
261
- def test_nowrap
262
- assert_respond_to(@table, :nowrap)
263
- assert_respond_to(@table, :nowrap=)
264
- assert_nothing_raised{ @table.nowrap }
265
- assert_nothing_raised{ @table.nowrap = false }
266
- end
267
-
268
- def test_nowrap_expected_errors
269
- assert_raises(TypeError){ @table.nowrap = 'foo' }
270
- end
271
-
272
- def test_rowspan
273
- assert_respond_to(@table, :rowspan)
274
- assert_respond_to(@table, :rowspan=)
275
- assert_nothing_raised{ @table.rowspan }
276
- assert_nothing_raised{ @table.rowspan = 1 }
277
- end
278
-
279
- def test_rowspan_expected_errors
280
- assert_raises(ArgumentError){ @table.rowspan = -1 }
281
- end
282
-
283
- def test_rules
284
- assert_respond_to(@table, :rules)
285
- assert_respond_to(@table, :rules=)
286
- assert_nothing_raised{ @table.rules }
287
- assert_nothing_raised{ @table.rules = 'all' }
288
- end
289
-
290
- def test_rules_expected_errors
291
- assert_raises(ArgumentError){ @table.rules = 'foo' }
292
- end
293
-
294
- def test_span
295
- assert_respond_to(@table, :span)
296
- assert_respond_to(@table, :span=)
297
- assert_nothing_raised{ @table.span }
298
- assert_nothing_raised{ @table.span = 1 }
299
- end
300
-
301
- def test_span_expected_errors
302
- assert_raises(ArgumentError){ @table.span = -1 }
303
- end
304
-
305
- def test_style
306
- assert_respond_to(@table, :style)
307
- assert_respond_to(@table, :style=)
308
- assert_nothing_raised{ @table.style }
309
- assert_nothing_raised{ @table.style = 'color: blue' }
310
- end
311
-
312
- def test_summary
313
- assert_respond_to(@table, :summary)
314
- assert_respond_to(@table, :summary=)
315
- assert_nothing_raised{ @table.summary }
316
- assert_nothing_raised{ @table.summary = 'foo' }
317
- assert_nothing_raised{ @table.summary = 1 }
318
- end
319
-
320
- def test_valign
321
- assert_respond_to(@table, :valign)
322
- assert_respond_to(@table, :valign=)
323
- assert_nothing_raised{ @table.valign }
324
- assert_nothing_raised{ @table.valign = 'center' }
325
- end
326
-
327
- def test_valign_expected_errors
328
- assert_raises(ArgumentError){ @table.valign = 'foo' }
329
- end
330
-
331
- def test_vspace
332
- assert_respond_to(@table, :vspace)
333
- assert_respond_to(@table, :vspace=)
334
- assert_nothing_raised{ @table.vspace }
335
- assert_nothing_raised{ @table.vspace = 1 }
336
- end
337
-
338
- def test_vspace_expected_errors
339
- assert_raises(ArgumentError){ @table.vspace = -1 }
340
- end
341
-
342
- def test_width
343
- assert_respond_to(@table, :width)
344
- assert_respond_to(@table, :width=)
345
- assert_nothing_raised{ @table.width}
346
- assert_nothing_raised{ @table.width = 10 }
347
- assert_nothing_raised{ @table.width = '5%' }
348
- end
349
-
350
- def test_width_expected_errors
351
- assert_raises(ArgumentError){ @table.width = -1 }
352
- end
353
-
354
- def teardown
355
- @table = nil
356
- end
357
-
358
- def self.shutdown
359
- NonStandardExtensionWarning.enable
360
- end
361
- end
data/test/test_body.rb DELETED
@@ -1,87 +0,0 @@
1
- ############################################
2
- # test_body.rb
3
- #
4
- # Test suite for the Table::Body class
5
- ############################################
6
- require 'test-unit'
7
- require 'html/table'
8
- include HTML
9
-
10
- class TC_HTML_Table_Body < Test::Unit::TestCase
11
- def setup
12
- @table = Table.new
13
- @tbody = Table::Body.new
14
- end
15
-
16
- def test_constructor
17
- assert_nothing_raised{ Table::Body.new }
18
- assert_nothing_raised{ Table::Body.new("foo") }
19
- assert_nothing_raised{ Table::Body.new(1) }
20
- assert_nothing_raised{ Table::Body.new(%w/foo bar baz/) }
21
- assert_nothing_raised{ Table::Body.new([1,2,3]) }
22
- assert_nothing_raised{ Table::Body.new([[1,2,3],["foo","bar"]]) }
23
- end
24
-
25
- def test_basic
26
- html = "<tbody></tbody>"
27
- assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
28
- end
29
-
30
- def test_with_attributes
31
- html = "<tbody align='left' char='x'></tbody>"
32
- @tbody.align = "left"
33
- @tbody.char = 'x'
34
- assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
35
- end
36
-
37
- def test_push_single_row
38
- html = "<tbody><tr><td>test</td></tr></tbody>"
39
- @tbody.push Table::Row.new{|r| r.content = "test" }
40
- assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
41
- end
42
-
43
- def test_push_multiple_rows
44
- html = "<tbody><tr><td>test</td></tr><tr><td>foo</td></tr></tbody>"
45
- r1 = Table::Row.new{|r| r.content = "test" }
46
- r2 = Table::Row.new{|r| r.content = "foo" }
47
- @tbody.push r1, r2
48
- assert_equal(html, @tbody.html.gsub(/\s{2,}|\n/,''))
49
- end
50
-
51
- def test_add_content_directly
52
- html = "<tbody><tr><td>hello</td><td>world</td></tr></tbody>"
53
- @tbody.content = "hello","world"
54
- assert_equal(html, @tbody.html.gsub(/\s{2,}|\n+/,''))
55
- end
56
-
57
- def test_add_content_in_constructor
58
- html = "<tbody><tr><td>hello</td><td>world</td></tr></tbody>"
59
- tb = Table::Body.new(%w/hello world/)
60
- assert_equal(html, tb.html.gsub(/\s{2,}|\n+/,''))
61
- end
62
-
63
- def test_configure_column
64
- html = "<tbody><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
65
- html += "</td></tr></tbody>"
66
- @tbody.content = "hello","world"
67
- @tbody.configure(0,1){ |data|
68
- data.abbr = 'test'
69
- data.width = 3
70
- data.nowrap = true
71
- }
72
- assert_equal(html, @tbody.html.gsub(/\s{2,}|\n+/,''))
73
- end
74
-
75
- def test_end_tags
76
- assert_respond_to(Table::Body, :end_tags?)
77
- assert_respond_to(Table::Body, :end_tags=)
78
- assert_raises(ArgumentTypeError){ Table::Body.end_tags = "foo" }
79
- assert_raises(ArgumentTypeError){ Table::Body.end_tags = 1 }
80
- assert_nothing_raised{ Table::Body.end_tags = true }
81
- end
82
-
83
- def teardown
84
- @table = nil
85
- @tbody = nil
86
- end
87
- end