html-table 1.7.0 → 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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/{CHANGES.rdoc → CHANGES.md} +73 -69
- data/Gemfile +2 -7
- data/{MANIFEST.rdoc → MANIFEST.md} +15 -15
- data/{README.rdoc → README.md} +80 -71
- data/Rakefile +7 -2
- data/doc/attributes.md +160 -0
- data/doc/table.md +173 -0
- data/doc/table_body.md +9 -0
- data/doc/table_caption.md +10 -0
- data/doc/table_colgroup.md +8 -0
- data/doc/table_colgroup_col.md +7 -0
- data/doc/table_content.md +17 -0
- data/doc/table_foot.md +8 -0
- data/doc/table_head.md +10 -0
- data/doc/table_row.md +114 -0
- data/doc/table_row_data.md +100 -0
- data/doc/table_row_header.md +6 -0
- data/examples/simple1.rb +7 -5
- data/html-table.gemspec +13 -8
- data/lib/html/body.rb +9 -7
- data/lib/html/caption.rb +4 -2
- data/lib/html/col.rb +37 -34
- data/lib/html/colgroup.rb +90 -97
- data/lib/html/content.rb +3 -6
- data/lib/html/data.rb +3 -1
- data/lib/html/foot.rb +53 -45
- data/lib/html/head.rb +54 -47
- data/lib/html/header.rb +5 -3
- data/lib/html/mixin/attribute_handler.rb +57 -53
- data/lib/html/mixin/html_handler.rb +33 -35
- data/lib/html/mixin/strongtyping.rb +6 -6
- data/lib/html/mixin/tag_handler.rb +6 -2
- data/lib/html/row.rb +156 -183
- data/lib/html/table.rb +45 -45
- data/lib/html/tablesection.rb +51 -46
- data/spec/attribute_handler_spec.rb +94 -80
- data/spec/body_spec.rb +54 -37
- data/spec/caption_spec.rb +41 -32
- data/spec/colgroup_col_spec.rb +7 -7
- data/spec/colgroup_spec.rb +50 -36
- data/spec/data_spec.rb +39 -23
- data/spec/foot_spec.rb +58 -46
- data/spec/head_spec.rb +62 -47
- data/spec/header_spec.rb +35 -22
- data/spec/html_handler_spec.rb +15 -12
- data/spec/row_spec.rb +95 -68
- data/spec/table_spec.rb +65 -31
- data/spec/tablesection_spec.rb +13 -13
- data/spec/tag_handler_spec.rb +13 -13
- data.tar.gz.sig +0 -0
- metadata +103 -78
- metadata.gz.sig +0 -0
- data/doc/attributes.rdoc +0 -143
- data/doc/table.rdoc +0 -156
- data/doc/table_body.rdoc +0 -9
- data/doc/table_caption.rdoc +0 -9
- data/doc/table_colgroup.rdoc +0 -8
- data/doc/table_colgroup_col.rdoc +0 -9
- data/doc/table_content.rdoc +0 -15
- data/doc/table_foot.rdoc +0 -8
- data/doc/table_head.rdoc +0 -11
- data/doc/table_row.rdoc +0 -105
- data/doc/table_row_data.rdoc +0 -92
- data/doc/table_row_header.rdoc +0 -7
@@ -13,348 +13,362 @@ RSpec.describe HTML::Mixin::AttributeHandler do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
before do
|
16
|
-
@table = HTML::Table.new(['foo',1,'bar'])
|
16
|
+
@table = HTML::Table.new(['foo', 1, 'bar'])
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
after(:all) do
|
20
|
+
NonStandardExtensionWarning.enable
|
21
|
+
end
|
22
|
+
|
23
|
+
example 'abbr_basic' do
|
20
24
|
expect(@table).to respond_to(:abbr)
|
21
25
|
expect(@table).to respond_to(:abbr=)
|
22
26
|
end
|
23
27
|
|
24
|
-
example
|
28
|
+
example 'abbr' do
|
25
29
|
expect{ @table.abbr }.not_to raise_error
|
26
30
|
expect(@table.abbr).to be_nil
|
27
31
|
expect{ @table.abbr = 'foo' }.not_to raise_error
|
28
|
-
expect(
|
32
|
+
expect(@table.abbr).to eq('foo')
|
29
33
|
end
|
30
34
|
|
31
|
-
example
|
35
|
+
example 'align_basic' do
|
32
36
|
expect(@table).to respond_to(:align)
|
33
37
|
expect(@table).to respond_to(:align=)
|
34
38
|
end
|
35
39
|
|
36
|
-
example
|
40
|
+
example 'align' do
|
37
41
|
expect{ @table.align }.not_to raise_error
|
38
42
|
expect(@table.align).to be_nil
|
39
43
|
expect{ @table.align = 'center' }.not_to raise_error
|
40
|
-
expect(
|
44
|
+
expect(@table.align).to eq('center')
|
41
45
|
end
|
42
46
|
|
43
|
-
example
|
47
|
+
example 'align_expected_errors' do
|
44
48
|
expect{ @table.align = 'foo' }.to raise_error(ArgumentError)
|
45
49
|
end
|
46
50
|
|
47
|
-
example
|
51
|
+
example 'axis' do
|
48
52
|
expect(@table).to respond_to(:axis)
|
49
53
|
expect(@table).to respond_to(:axis=)
|
50
54
|
expect{ @table.axis }.not_to raise_error
|
51
55
|
expect{ @table.axis = 'foo' }.not_to raise_error
|
52
56
|
end
|
53
57
|
|
54
|
-
example
|
58
|
+
example 'background_basic' do
|
55
59
|
expect(@table).to respond_to(:background)
|
56
60
|
expect(@table).to respond_to(:background=)
|
57
61
|
end
|
58
62
|
|
59
|
-
example
|
63
|
+
example 'background' do
|
60
64
|
expect{ @table.background }.not_to raise_error
|
61
65
|
expect(@table.background).to be_nil
|
62
66
|
expect{ @table.background = 'foo' }.not_to raise_error
|
63
|
-
expect(
|
67
|
+
expect(@table.background).to eq('foo')
|
64
68
|
end
|
65
69
|
|
66
|
-
example
|
70
|
+
example 'background_expected_errors' do
|
67
71
|
expect{ @table.background = 1 }.to raise_error(TypeError)
|
68
72
|
end
|
69
73
|
|
70
|
-
example
|
74
|
+
example 'bgcolor_basic' do
|
71
75
|
expect(@table).to respond_to(:bgcolor)
|
72
76
|
expect(@table).to respond_to(:bgcolor=)
|
73
77
|
end
|
74
78
|
|
75
|
-
example
|
79
|
+
example 'bgcolor' do
|
76
80
|
expect{ @table.bgcolor }.not_to raise_error
|
77
81
|
expect(@table.bgcolor).to be_nil
|
78
82
|
expect{ @table.bgcolor = 'foo' }.not_to raise_error
|
79
|
-
expect(
|
83
|
+
expect(@table.bgcolor).to eq('foo')
|
80
84
|
end
|
81
85
|
|
82
|
-
example
|
86
|
+
example 'border_basic' do
|
83
87
|
expect(@table).to respond_to(:border)
|
84
88
|
expect(@table).to respond_to(:border=)
|
85
89
|
end
|
86
90
|
|
87
|
-
example
|
91
|
+
example 'border' do
|
88
92
|
expect{ @table.border }.not_to raise_error
|
89
93
|
expect{ @table.border = 2 }.not_to raise_error
|
90
94
|
expect{ @table.border = true }.not_to raise_error
|
91
95
|
expect{ @table.border = false }.not_to raise_error
|
92
96
|
end
|
93
97
|
|
94
|
-
example
|
98
|
+
example 'bordercolor_basic' do
|
95
99
|
expect(@table).to respond_to(:bordercolor)
|
96
100
|
expect(@table).to respond_to(:bordercolor=)
|
97
101
|
end
|
98
102
|
|
99
|
-
example
|
103
|
+
example 'bordercolor' do
|
100
104
|
expect{ @table.bordercolor }.not_to raise_error
|
101
105
|
expect(@table.bordercolor).to be_nil
|
102
106
|
expect{ @table.bordercolor = 'foo' }.not_to raise_error
|
103
|
-
expect(
|
107
|
+
expect(@table.bordercolor).to eq('foo')
|
104
108
|
end
|
105
109
|
|
106
|
-
example
|
110
|
+
example 'bordercolordark_basic' do
|
107
111
|
expect(@table).to respond_to(:bordercolordark)
|
108
112
|
expect(@table).to respond_to(:bordercolordark=)
|
109
113
|
end
|
110
114
|
|
111
|
-
example
|
115
|
+
example 'bordercolordark' do
|
112
116
|
expect{ @table.bordercolordark }.not_to raise_error
|
113
117
|
expect(@table.bordercolordark).to be_nil
|
114
118
|
expect{ @table.bordercolordark = 'foo' }.not_to raise_error
|
115
|
-
expect(
|
119
|
+
expect(@table.bordercolordark).to eq('foo')
|
116
120
|
end
|
117
121
|
|
118
|
-
example
|
122
|
+
example 'bordercolorlight' do
|
119
123
|
expect(@table).to respond_to(:bordercolorlight)
|
120
124
|
expect(@table).to respond_to(:bordercolorlight=)
|
121
125
|
expect{ @table.bordercolorlight }.not_to raise_error
|
122
126
|
expect{ @table.bordercolorlight = 'foo' }.not_to raise_error
|
123
127
|
end
|
124
128
|
|
125
|
-
example
|
129
|
+
example 'cellpadding' do
|
126
130
|
expect(@table).to respond_to(:cellpadding)
|
127
131
|
expect(@table).to respond_to(:cellpadding=)
|
128
132
|
expect{ @table.cellpadding }.not_to raise_error
|
129
133
|
expect{ @table.cellpadding = 1 }.not_to raise_error
|
130
134
|
end
|
131
135
|
|
132
|
-
example
|
136
|
+
example 'cellpadding_expected_errors' do
|
133
137
|
expect{ @table.cellpadding = -1 }.to raise_error(ArgumentError)
|
134
138
|
end
|
135
139
|
|
136
|
-
example
|
140
|
+
example 'cellspacing' do
|
137
141
|
expect(@table).to respond_to(:cellspacing)
|
138
142
|
expect(@table).to respond_to(:cellspacing=)
|
139
143
|
expect{ @table.cellspacing }.not_to raise_error
|
140
144
|
expect{ @table.cellspacing = 1 }.not_to raise_error
|
141
145
|
end
|
142
146
|
|
143
|
-
example
|
147
|
+
example 'cellspacing_expected_errors' do
|
144
148
|
expect{ @table.cellspacing = -1 }.to raise_error(ArgumentError)
|
145
149
|
end
|
146
150
|
|
147
|
-
example
|
151
|
+
example 'char' do
|
148
152
|
expect(@table).to respond_to(:char)
|
149
153
|
expect(@table).to respond_to(:char=)
|
150
154
|
expect{ @table.char }.not_to raise_error
|
151
155
|
expect{ @table.char = 'x' }.not_to raise_error
|
152
156
|
end
|
153
157
|
|
154
|
-
example
|
158
|
+
example 'char_expected_errors' do
|
155
159
|
expect{ @table.char = 'xx' }.to raise_error(ArgumentError)
|
156
160
|
end
|
157
161
|
|
158
|
-
example
|
162
|
+
example 'charoff' do
|
159
163
|
expect(@table).to respond_to(:charoff)
|
160
164
|
expect(@table).to respond_to(:charoff=)
|
161
165
|
expect{ @table.charoff }.not_to raise_error
|
162
166
|
expect{ @table.charoff = 1 }.not_to raise_error
|
163
167
|
end
|
164
168
|
|
165
|
-
example
|
169
|
+
example 'charoff_expected_errors' do
|
166
170
|
expect{ @table.charoff = -1 }.to raise_error(ArgumentError)
|
167
171
|
end
|
168
172
|
|
169
|
-
example
|
173
|
+
example 'class' do
|
170
174
|
expect(@table).to respond_to(:class_)
|
171
175
|
expect(@table).to respond_to(:class_=)
|
172
176
|
expect{ @table.class_ }.not_to raise_error
|
173
177
|
expect{ @table.class_ = 'myclass' }.not_to raise_error
|
174
178
|
end
|
175
179
|
|
176
|
-
example
|
180
|
+
example 'col' do
|
177
181
|
expect(@table).to respond_to(:col)
|
178
182
|
expect(@table).to respond_to(:col=)
|
179
183
|
expect{ @table.col }.not_to raise_error
|
180
184
|
expect{ @table.col = 1 }.not_to raise_error
|
181
185
|
end
|
182
186
|
|
183
|
-
example
|
187
|
+
example 'col_expected_errors' do
|
184
188
|
expect{ @table.col = -1 }.to raise_error(ArgumentError)
|
185
189
|
end
|
186
190
|
|
187
|
-
example
|
191
|
+
example 'colspan' do
|
188
192
|
expect(@table).to respond_to(:colspan)
|
189
193
|
expect(@table).to respond_to(:colspan=)
|
190
194
|
expect{ @table.colspan }.not_to raise_error
|
191
195
|
expect{ @table.colspan = 1 }.not_to raise_error
|
192
196
|
end
|
193
197
|
|
194
|
-
example
|
198
|
+
example 'colspan_expected_errors' do
|
195
199
|
expect{ @table.colspan = -1 }.to raise_error(ArgumentError)
|
196
200
|
end
|
197
201
|
|
198
|
-
example
|
202
|
+
example 'configure' do
|
199
203
|
expect(@table).to respond_to(:configure)
|
200
|
-
expect{ @table.configure(0){}.not_to raise_error
|
201
|
-
expect{ @table.configure(0,0){}.not_to raise_error
|
204
|
+
expect{ @table.configure(0){} }.not_to raise_error
|
205
|
+
expect{ @table.configure(0, 0){} }.not_to raise_error
|
202
206
|
end
|
203
207
|
|
204
|
-
example
|
205
|
-
expect{ @table.configure(0,0,0){}.to raise_error(ArgumentError)
|
208
|
+
example 'configure_expected_errors' do
|
209
|
+
expect{ @table.configure(0, 0, 0){} }.to raise_error(ArgumentError)
|
206
210
|
end
|
207
211
|
|
208
|
-
|
209
|
-
# This test could probably be broken out into separate tests for each
|
210
|
-
# type that we want to add as content.
|
211
|
-
########################################################################
|
212
|
-
example "content" do
|
212
|
+
example 'content' do
|
213
213
|
expect(@table).to respond_to(:content)
|
214
214
|
expect(@table).to respond_to(:content=)
|
215
|
+
end
|
216
|
+
|
217
|
+
example 'content= with string' do
|
215
218
|
expect{ @table.content = 'foo' }.not_to raise_error
|
219
|
+
end
|
220
|
+
|
221
|
+
example 'content= with numeric' do
|
216
222
|
expect{ @table.content = 123 }.not_to raise_error
|
217
|
-
|
218
|
-
|
223
|
+
end
|
224
|
+
|
225
|
+
example 'content= with array' do
|
226
|
+
expect{ @table.content = ['one', 2, 'three'] }.not_to raise_error
|
227
|
+
expect{ @table.content = [%w[foo bar], [1, 2, 3]] }.not_to raise_error
|
228
|
+
end
|
229
|
+
|
230
|
+
example 'content= with explicit row types' do
|
219
231
|
expect{ @table.content = HTML::Table::Row.new }.not_to raise_error
|
220
232
|
expect{ @table.content = HTML::Table::Row::Data.new }.not_to raise_error
|
221
233
|
expect{ @table.content = HTML::Table::Row::Header.new }.not_to raise_error
|
234
|
+
end
|
235
|
+
|
236
|
+
example 'content= with other table types' do
|
222
237
|
expect{ @table.content = HTML::Table::Head.create }.not_to raise_error
|
223
238
|
expect{ @table.content = HTML::Table::Foot.create }.not_to raise_error
|
224
239
|
expect{ @table.content = HTML::Table::Body.new }.not_to raise_error
|
225
240
|
end
|
226
241
|
|
227
|
-
example
|
242
|
+
example 'frame' do
|
228
243
|
expect(@table).to respond_to(:frame)
|
229
244
|
expect(@table).to respond_to(:frame=)
|
230
245
|
expect{ @table.frame }.not_to raise_error
|
231
246
|
expect{ @table.frame = 'below' }.not_to raise_error
|
232
247
|
end
|
233
248
|
|
234
|
-
example
|
249
|
+
example 'frame_expected_errors' do
|
235
250
|
expect{ @table.frame = 'foo' }.to raise_error(ArgumentError)
|
236
251
|
end
|
237
252
|
|
238
|
-
example
|
253
|
+
example 'height' do
|
239
254
|
expect(@table).to respond_to(:height)
|
240
255
|
expect(@table).to respond_to(:height=)
|
241
256
|
expect{ @table.height }.not_to raise_error
|
242
257
|
expect{ @table.height = 1 }.not_to raise_error
|
243
258
|
end
|
244
259
|
|
245
|
-
example
|
260
|
+
example 'height_expected_errors' do
|
246
261
|
expect{ @table.height = -1 }.to raise_error(ArgumentError)
|
247
262
|
end
|
248
263
|
|
249
|
-
example
|
264
|
+
example 'hspace' do
|
250
265
|
expect(@table).to respond_to(:hspace)
|
251
266
|
expect(@table).to respond_to(:hspace=)
|
252
267
|
expect{ @table.hspace }.not_to raise_error
|
253
268
|
expect{ @table.hspace = 1 }.not_to raise_error
|
254
269
|
end
|
255
270
|
|
256
|
-
example
|
271
|
+
example 'hspace_expected_errors' do
|
257
272
|
expect{ @table.hspace = -1 }.to raise_error(ArgumentError)
|
258
273
|
end
|
259
274
|
|
260
|
-
example
|
275
|
+
example 'nowrap' do
|
261
276
|
expect(@table).to respond_to(:nowrap)
|
262
277
|
expect(@table).to respond_to(:nowrap=)
|
263
278
|
expect{ @table.nowrap }.not_to raise_error
|
264
279
|
expect{ @table.nowrap = false }.not_to raise_error
|
265
280
|
end
|
266
281
|
|
267
|
-
example
|
282
|
+
example 'nowrap_expected_errors' do
|
268
283
|
expect{ @table.nowrap = 'foo' }.to raise_error(TypeError)
|
269
284
|
end
|
270
285
|
|
271
|
-
example
|
286
|
+
example 'rowspan' do
|
272
287
|
expect(@table).to respond_to(:rowspan)
|
273
288
|
expect(@table).to respond_to(:rowspan=)
|
274
289
|
expect{ @table.rowspan }.not_to raise_error
|
275
290
|
expect{ @table.rowspan = 1 }.not_to raise_error
|
276
291
|
end
|
277
292
|
|
278
|
-
example
|
293
|
+
example 'rowspan_expected_errors' do
|
279
294
|
expect{ @table.rowspan = -1 }.to raise_error(ArgumentError)
|
280
295
|
end
|
281
296
|
|
282
|
-
example
|
297
|
+
example 'rules' do
|
283
298
|
expect(@table).to respond_to(:rules)
|
284
299
|
expect(@table).to respond_to(:rules=)
|
285
300
|
expect{ @table.rules }.not_to raise_error
|
286
301
|
expect{ @table.rules = 'all' }.not_to raise_error
|
287
302
|
end
|
288
303
|
|
289
|
-
example
|
304
|
+
example 'rules_expected_errors' do
|
290
305
|
expect{ @table.rules = 'foo' }.to raise_error(ArgumentError)
|
291
306
|
end
|
292
307
|
|
293
|
-
example
|
308
|
+
example 'span' do
|
294
309
|
expect(@table).to respond_to(:span)
|
295
310
|
expect(@table).to respond_to(:span=)
|
296
311
|
expect{ @table.span }.not_to raise_error
|
297
312
|
expect{ @table.span = 1 }.not_to raise_error
|
298
313
|
end
|
299
314
|
|
300
|
-
example
|
315
|
+
example 'span_expected_errors' do
|
301
316
|
expect{ @table.span = -1 }.to raise_error(ArgumentError)
|
302
317
|
end
|
303
318
|
|
304
|
-
example
|
319
|
+
example 'style' do
|
305
320
|
expect(@table).to respond_to(:style)
|
306
321
|
expect(@table).to respond_to(:style=)
|
307
322
|
expect{ @table.style }.not_to raise_error
|
308
323
|
expect{ @table.style = 'color: blue' }.not_to raise_error
|
309
324
|
end
|
310
325
|
|
311
|
-
example
|
326
|
+
example 'summary' do
|
312
327
|
expect(@table).to respond_to(:summary)
|
313
|
-
expect(@table).to respond_to(:summary=)
|
314
328
|
expect{ @table.summary }.not_to raise_error
|
329
|
+
end
|
330
|
+
|
331
|
+
example 'summary=' do
|
332
|
+
expect(@table).to respond_to(:summary=)
|
315
333
|
expect{ @table.summary = 'foo' }.not_to raise_error
|
316
334
|
expect{ @table.summary = 1 }.not_to raise_error
|
317
335
|
end
|
318
336
|
|
319
|
-
example
|
337
|
+
example 'valign' do
|
320
338
|
expect(@table).to respond_to(:valign)
|
321
339
|
expect(@table).to respond_to(:valign=)
|
322
340
|
expect{ @table.valign }.not_to raise_error
|
323
341
|
expect{ @table.valign = 'center' }.not_to raise_error
|
324
342
|
end
|
325
343
|
|
326
|
-
example
|
344
|
+
example 'valign_expected_errors' do
|
327
345
|
expect{ @table.valign = 'foo' }.to raise_error(ArgumentError)
|
328
346
|
end
|
329
347
|
|
330
|
-
example
|
348
|
+
example 'vspace' do
|
331
349
|
expect(@table).to respond_to(:vspace)
|
332
350
|
expect(@table).to respond_to(:vspace=)
|
333
351
|
expect{ @table.vspace }.not_to raise_error
|
334
352
|
expect{ @table.vspace = 1 }.not_to raise_error
|
335
353
|
end
|
336
354
|
|
337
|
-
example
|
355
|
+
example 'vspace_expected_errors' do
|
338
356
|
expect{ @table.vspace = -1 }.to raise_error(ArgumentError)
|
339
357
|
end
|
340
358
|
|
341
|
-
example
|
359
|
+
example 'width' do
|
342
360
|
expect(@table).to respond_to(:width)
|
343
361
|
expect(@table).to respond_to(:width=)
|
344
|
-
expect{ @table.width}.not_to raise_error
|
362
|
+
expect{ @table.width }.not_to raise_error
|
345
363
|
expect{ @table.width = 10 }.not_to raise_error
|
346
364
|
end
|
347
365
|
|
348
|
-
example
|
366
|
+
example 'width_with_percent' do
|
349
367
|
expect{ @table.width = '5%' }.not_to raise_error
|
350
|
-
expect(
|
368
|
+
expect(@table.width).to eq('5%')
|
351
369
|
end
|
352
370
|
|
353
|
-
example
|
371
|
+
example 'width_expected_errors' do
|
354
372
|
expect{ @table.width = -1 }.to raise_error(ArgumentError)
|
355
373
|
end
|
356
|
-
|
357
|
-
after(:all) do
|
358
|
-
NonStandardExtensionWarning.enable
|
359
|
-
end
|
360
374
|
end
|
data/spec/body_spec.rb
CHANGED
@@ -9,73 +9,90 @@ require 'html/table'
|
|
9
9
|
RSpec.describe HTML::Table::Body do
|
10
10
|
before do
|
11
11
|
@table = HTML::Table.new
|
12
|
-
@tbody =
|
12
|
+
@tbody = described_class.new
|
13
13
|
end
|
14
14
|
|
15
|
-
example
|
16
|
-
expect{
|
17
|
-
expect{ HTML::Table::Body.new("foo") }.not_to raise_error
|
18
|
-
expect{ HTML::Table::Body.new(1) }.not_to raise_error
|
19
|
-
expect{ HTML::Table::Body.new(%w/foo bar baz/) }.not_to raise_error
|
20
|
-
expect{ HTML::Table::Body.new([1,2,3]) }.not_to raise_error
|
21
|
-
expect{ HTML::Table::Body.new([[1,2,3],["foo","bar"]]) }.not_to raise_error
|
15
|
+
example 'constructor with no arguments' do
|
16
|
+
expect{ described_class.new }.not_to raise_error
|
22
17
|
end
|
23
18
|
|
24
|
-
example
|
25
|
-
|
19
|
+
example 'constructor with string argument' do
|
20
|
+
expect{ described_class.new('foo') }.not_to raise_error
|
21
|
+
end
|
22
|
+
|
23
|
+
example 'constructor with numeric argument' do
|
24
|
+
expect{ described_class.new(1) }.not_to raise_error
|
25
|
+
end
|
26
|
+
|
27
|
+
example 'constructor with array argument' do
|
28
|
+
expect{ described_class.new(%w[foo bar baz]) }.not_to raise_error
|
29
|
+
expect{ described_class.new([1, 2, 3]) }.not_to raise_error
|
30
|
+
end
|
31
|
+
|
32
|
+
example 'constructor with multiple array arguments' do
|
33
|
+
expect{ described_class.new([[1, 2, 3], %w[foo bar]]) }.not_to raise_error
|
34
|
+
end
|
35
|
+
|
36
|
+
example 'basic' do
|
37
|
+
html = '<tbody></tbody>'
|
26
38
|
expect(@tbody.html.gsub(/\s{2,}|\n/, '')).to eq(html)
|
27
39
|
end
|
28
40
|
|
29
|
-
example
|
41
|
+
example 'with_attributes' do
|
30
42
|
html = "<tbody align='left' char='x'></tbody>"
|
31
|
-
@tbody.align =
|
43
|
+
@tbody.align = 'left'
|
32
44
|
@tbody.char = 'x'
|
33
45
|
expect(@tbody.html.gsub(/\s{2,}|\n/, '')).to eq(html)
|
34
46
|
end
|
35
47
|
|
36
|
-
example
|
37
|
-
html =
|
38
|
-
@tbody.push
|
48
|
+
example 'push_single_row' do
|
49
|
+
html = '<tbody><tr><td>test</td></tr></tbody>'
|
50
|
+
@tbody.push(HTML::Table::Row.new{ |r| r.content = 'test' })
|
39
51
|
expect(@tbody.html.gsub(/\s{2,}|\n/, '')).to eq(html)
|
40
52
|
end
|
41
53
|
|
42
|
-
example
|
43
|
-
html =
|
44
|
-
r1 = HTML::Table::Row.new{|r| r.content =
|
45
|
-
r2 = HTML::Table::Row.new{|r| r.content =
|
54
|
+
example 'push_multiple_rows' do
|
55
|
+
html = '<tbody><tr><td>test</td></tr><tr><td>foo</td></tr></tbody>'
|
56
|
+
r1 = HTML::Table::Row.new{ |r| r.content = 'test' }
|
57
|
+
r2 = HTML::Table::Row.new{ |r| r.content = 'foo' }
|
46
58
|
@tbody.push r1, r2
|
47
59
|
expect(@tbody.html.gsub(/\s{2,}|\n/, '')).to eq(html)
|
48
60
|
end
|
49
61
|
|
50
|
-
example
|
51
|
-
html =
|
52
|
-
@tbody.content =
|
62
|
+
example 'add_content_directly' do
|
63
|
+
html = '<tbody><tr><td>hello</td><td>world</td></tr></tbody>'
|
64
|
+
@tbody.content = 'hello', 'world'
|
53
65
|
expect(@tbody.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
|
54
66
|
end
|
55
67
|
|
56
|
-
example
|
57
|
-
html =
|
58
|
-
tb =
|
68
|
+
example 'add_content_in_constructor' do
|
69
|
+
html = '<tbody><tr><td>hello</td><td>world</td></tr></tbody>'
|
70
|
+
tb = described_class.new(%w[hello world])
|
59
71
|
expect(tb.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
|
60
72
|
end
|
61
73
|
|
62
|
-
example
|
63
|
-
html = "<tbody><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
|
64
|
-
|
65
|
-
@tbody.content =
|
66
|
-
@tbody.configure(0,1)
|
74
|
+
example 'configure_column' do
|
75
|
+
html = "<tbody><tr><td>hello</td><td abbr='test' width=3 nowrap>world</td></tr></tbody>"
|
76
|
+
|
77
|
+
@tbody.content = 'hello', 'world'
|
78
|
+
@tbody.configure(0, 1) do |data|
|
67
79
|
data.abbr = 'test'
|
68
80
|
data.width = 3
|
69
81
|
data.nowrap = true
|
70
|
-
|
82
|
+
end
|
83
|
+
|
71
84
|
expect(@tbody.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
|
72
85
|
end
|
73
86
|
|
74
|
-
example
|
75
|
-
expect(
|
76
|
-
expect(
|
77
|
-
|
78
|
-
|
79
|
-
|
87
|
+
example 'end_tags?' do
|
88
|
+
expect(described_class).to respond_to(:end_tags?)
|
89
|
+
expect(described_class.end_tags?).to be(true)
|
90
|
+
end
|
91
|
+
|
92
|
+
example 'end_tags=' do
|
93
|
+
expect(described_class).to respond_to(:end_tags=)
|
94
|
+
expect{ described_class.end_tags = 'foo' }.to raise_error(ArgumentTypeError)
|
95
|
+
expect{ described_class.end_tags = 1 }.to raise_error(ArgumentTypeError)
|
96
|
+
expect{ described_class.end_tags = true }.not_to raise_error
|
80
97
|
end
|
81
98
|
end
|