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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/{CHANGES.rdoc → CHANGES.md} +76 -68
- data/Gemfile +2 -0
- data/MANIFEST.md +57 -0
- data/{README.rdoc → README.md} +80 -71
- data/Rakefile +122 -146
- 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 +16 -11
- 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 +59 -55
- 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 +374 -0
- data/spec/body_spec.rb +98 -0
- data/spec/caption_spec.rb +83 -0
- data/spec/colgroup_col_spec.rb +34 -0
- data/spec/colgroup_spec.rb +97 -0
- data/spec/data_spec.rb +88 -0
- data/spec/foot_spec.rb +116 -0
- data/spec/head_spec.rb +116 -0
- data/spec/header_spec.rb +85 -0
- data/spec/html_handler_spec.rb +35 -0
- data/spec/row_spec.rb +163 -0
- data/spec/table_spec.rb +186 -0
- data/spec/tablesection_spec.rb +36 -0
- data/spec/tag_handler_spec.rb +85 -0
- data.tar.gz.sig +0 -0
- metadata +118 -92
- metadata.gz.sig +0 -0
- data/MANIFEST.rdoc +0 -56
- 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
- data/test/test_attribute_handler.rb +0 -361
- data/test/test_body.rb +0 -87
- data/test/test_caption.rb +0 -80
- data/test/test_col.rb +0 -40
- data/test/test_colgroup.rb +0 -89
- data/test/test_data.rb +0 -77
- data/test/test_foot.rb +0 -111
- data/test/test_head.rb +0 -104
- data/test/test_header.rb +0 -77
- data/test/test_html_handler.rb +0 -37
- data/test/test_row.rb +0 -141
- data/test/test_table.rb +0 -159
- data/test/test_tablesection.rb +0 -42
- data/test/test_tag_handler.rb +0 -90
data/lib/html/table.rb
CHANGED
@@ -2,7 +2,6 @@ require_relative 'mixin/attribute_handler'
|
|
2
2
|
require_relative 'mixin/html_handler'
|
3
3
|
require_relative 'mixin/strongtyping'
|
4
4
|
require 'structured_warnings'
|
5
|
-
include HTML::Mixin::StrongTyping
|
6
5
|
|
7
6
|
# Warning raised if a non-standard extension is used.
|
8
7
|
class NonStandardExtensionWarning < StructuredWarnings::StandardWarning; end
|
@@ -10,6 +9,9 @@ class NonStandardExtensionWarning < StructuredWarnings::StandardWarning; end
|
|
10
9
|
# Please, think of the children before using the blink tag.
|
11
10
|
class BlinkWarning < StructuredWarnings::StandardWarning; end
|
12
11
|
|
12
|
+
# Used by the strongtyping mixin.
|
13
|
+
class ArgumentTypeError < ArgumentError; end
|
14
|
+
|
13
15
|
# The HTML module serves as a namespace only.
|
14
16
|
module HTML
|
15
17
|
|
@@ -18,9 +20,11 @@ module HTML
|
|
18
20
|
class Table < Array
|
19
21
|
include HTML::Mixin::AttributeHandler
|
20
22
|
include HTML::Mixin::HtmlHandler
|
23
|
+
include HTML::Mixin::StrongTyping
|
24
|
+
extend HTML::Mixin::StrongTyping
|
21
25
|
|
22
26
|
# The version of the html-table library
|
23
|
-
VERSION = '1.
|
27
|
+
VERSION = '1.7.1'.freeze
|
24
28
|
|
25
29
|
# The indentation level for the <table> and </table> tags
|
26
30
|
@indent_level = 0
|
@@ -29,7 +33,7 @@ module HTML
|
|
29
33
|
@html_case = 'lower'
|
30
34
|
|
31
35
|
# Determines whether or not end tags will be included in printed output
|
32
|
-
|
36
|
+
@global_end_tags = true
|
33
37
|
|
34
38
|
# Returns a new Table object. Optionally takes a block which is
|
35
39
|
# eval'd if provided. If an argument is provided it is interpreted as
|
@@ -94,9 +98,9 @@ module HTML
|
|
94
98
|
self.content = arg if arg
|
95
99
|
|
96
100
|
# Assume html_options are attributes
|
97
|
-
html_options.each
|
98
|
-
|
99
|
-
|
101
|
+
html_options.each do |key, val|
|
102
|
+
send("#{key}=", val)
|
103
|
+
end
|
100
104
|
end
|
101
105
|
|
102
106
|
# Adds content to the table. How this method behaves depends on the
|
@@ -108,8 +112,8 @@ module HTML
|
|
108
112
|
# object is created, with the string as the content.
|
109
113
|
#
|
110
114
|
def content=(arg)
|
111
|
-
if arg.
|
112
|
-
arg.each{ |e| self << Table::Row.new(e) }
|
115
|
+
if arg.is_a?(Array)
|
116
|
+
arg.each { |e| self << Table::Row.new(e) }
|
113
117
|
else
|
114
118
|
self << Table::Row.new(arg)
|
115
119
|
end
|
@@ -128,8 +132,8 @@ module HTML
|
|
128
132
|
# object.
|
129
133
|
#
|
130
134
|
def header=(arg)
|
131
|
-
if arg.
|
132
|
-
arg.each{ |h| self << Table::Row.new(h, true) }
|
135
|
+
if arg.is_a?(Array)
|
136
|
+
arg.each { |h| self << Table::Row.new(h, true) }
|
133
137
|
else
|
134
138
|
self << Table::Row::Header.new(arg)
|
135
139
|
end
|
@@ -139,18 +143,18 @@ module HTML
|
|
139
143
|
# turned on or off, respectively.
|
140
144
|
#
|
141
145
|
def self.global_end_tags?
|
142
|
-
|
146
|
+
@global_end_tags
|
143
147
|
end
|
144
148
|
|
145
|
-
# Sets the end tag class variable.
|
146
|
-
# to include optional end tags in the final HTML output.
|
147
|
-
# sent to this method must be true or false.
|
149
|
+
# Sets the end tag class variable. This is used to set whether or not
|
150
|
+
# to include optional end tags in the final HTML output. The argument
|
151
|
+
# sent to this method must be true or false. The default value is true.
|
148
152
|
#
|
149
153
|
# Note that mandatory end tags are unaffected by this setting.
|
150
154
|
#
|
151
155
|
def self.global_end_tags=(bool)
|
152
156
|
expect(bool, [TrueClass, FalseClass])
|
153
|
-
|
157
|
+
@global_end_tags = bool
|
154
158
|
end
|
155
159
|
|
156
160
|
# Returns either "lower" or "upper", indicating the case of all HTML
|
@@ -160,13 +164,13 @@ module HTML
|
|
160
164
|
@html_case
|
161
165
|
end
|
162
166
|
|
163
|
-
# Sets the case of all HTML tags to either lower or upper.
|
167
|
+
# Sets the case of all HTML tags to either lower or upper. The only
|
164
168
|
# valid arguments to this method are 'upper' or 'lower'.
|
165
169
|
#
|
166
170
|
def self.html_case=(arg)
|
167
171
|
expect(arg, String)
|
168
172
|
arg.downcase!
|
169
|
-
unless
|
173
|
+
unless %w[upper lower].include?(arg)
|
170
174
|
msg = "Argument to html_case() must be 'upper' or 'lower'"
|
171
175
|
raise ArgumentError, msg
|
172
176
|
end
|
@@ -187,7 +191,7 @@ module HTML
|
|
187
191
|
#
|
188
192
|
def self.indent_level=(num)
|
189
193
|
expect(num, Integer)
|
190
|
-
raise ArgumentError,
|
194
|
+
raise ArgumentError, 'indent level must be >= 0' if num < 0
|
191
195
|
@indent_level = num
|
192
196
|
end
|
193
197
|
|
@@ -200,30 +204,30 @@ module HTML
|
|
200
204
|
# only be assigned to index 0, or index 1 if a Caption already exists.
|
201
205
|
# A Foot may only be assigned as the last element.
|
202
206
|
#
|
203
|
-
def []=(index,obj)
|
207
|
+
def []=(index, obj)
|
204
208
|
expect(obj, [Caption, ColGroup, Body, Foot, Head, Row])
|
205
209
|
|
206
210
|
# Only allow Caption objects at index 0
|
207
|
-
if index != 0 && obj.
|
208
|
-
msg =
|
211
|
+
if index != 0 && obj.is_a?(HTML::Table::Caption)
|
212
|
+
msg = 'CAPTION can only be added at index 0'
|
209
213
|
raise ArgumentError, msg
|
210
214
|
end
|
211
215
|
|
212
216
|
# Only allow Head objects at index 0 or 1
|
213
|
-
if obj.
|
214
|
-
if self[0].
|
215
|
-
msg =
|
217
|
+
if obj.is_a?(HTML::Table::Head)
|
218
|
+
if self[0].is_a?(HTML::Table::Caption) && index != 1
|
219
|
+
msg = 'THEAD must be at index 1 when Caption is included'
|
216
220
|
raise ArgumentError, msg
|
217
221
|
end
|
218
222
|
|
219
|
-
if !self[0].
|
220
|
-
msg =
|
223
|
+
if !self[0].is_a?(HTML::Table::Caption) && index != 0
|
224
|
+
msg = 'THEAD must be at index 0 when no Caption is included'
|
221
225
|
raise ArgumentError, msg
|
222
226
|
end
|
223
227
|
end
|
224
228
|
|
225
|
-
if obj.
|
226
|
-
msg =
|
229
|
+
if obj.is_a?(HTML::Table::Foot) && index != -1
|
230
|
+
msg = 'FOOT must be last element'
|
227
231
|
raise ArgumentError, msg
|
228
232
|
end
|
229
233
|
|
@@ -242,29 +246,27 @@ module HTML
|
|
242
246
|
# element, or the second element if a Caption already exists.
|
243
247
|
#
|
244
248
|
def push(*args)
|
245
|
-
args.each
|
249
|
+
args.each do |obj|
|
246
250
|
expect(obj, [Caption, ColGroup, Body, Foot, Head, Row, Row::Data, Row::Header])
|
247
251
|
|
248
252
|
case obj
|
249
253
|
when Table::Row::Data, Table::Row::Header
|
250
|
-
|
254
|
+
push(Table::Row.new(obj))
|
251
255
|
when Table::Caption
|
252
|
-
if self[0].
|
256
|
+
if self[0].is_a?(Table::Caption)
|
253
257
|
self[0] = obj
|
254
258
|
else
|
255
|
-
|
259
|
+
unshift(obj)
|
256
260
|
end
|
257
261
|
when Table::Head
|
258
|
-
|
259
|
-
|
260
|
-
self[0],self[1] = self[1],self[0]
|
261
|
-
else
|
262
|
-
self.unshift(obj)
|
262
|
+
unshift(obj)
|
263
|
+
if self[0].is_a?(Table::Caption)
|
264
|
+
self[0], self[1] = self[1], self[0]
|
263
265
|
end
|
264
266
|
else
|
265
267
|
super(obj)
|
266
268
|
end
|
267
|
-
|
269
|
+
end
|
268
270
|
end
|
269
271
|
|
270
272
|
# This method has been redefined to only allow certain subclasses to
|
@@ -279,20 +281,18 @@ module HTML
|
|
279
281
|
when Table::Row::Data, Table::Row::Header # Each get their own row
|
280
282
|
self << Table::Row.new(obj)
|
281
283
|
when Table::Caption # Always the first row
|
282
|
-
if self[0].
|
284
|
+
if self[0].is_a?(Table::Caption)
|
283
285
|
self[0] = obj
|
284
286
|
else
|
285
|
-
|
287
|
+
unshift(obj)
|
286
288
|
end
|
287
289
|
when Table::Head # Always at row 0 or 1
|
288
|
-
|
289
|
-
|
290
|
+
unshift(obj)
|
291
|
+
if self[0].is_a?(Table::Caption)
|
290
292
|
self[0], self[1] = self[1], self[0]
|
291
|
-
else
|
292
|
-
self.unshift(obj)
|
293
293
|
end
|
294
294
|
else
|
295
|
-
super
|
295
|
+
super
|
296
296
|
end
|
297
297
|
end
|
298
298
|
|
data/lib/html/tablesection.rb
CHANGED
@@ -1,48 +1,53 @@
|
|
1
|
+
# The HTML module serves as a namespace only.
|
1
2
|
module HTML
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
3
|
+
|
4
|
+
# Superclass for THEAD, TBODY, TFOOT
|
5
|
+
#
|
6
|
+
class Table::TableSection < Array
|
7
|
+
include HTML::Mixin::AttributeHandler
|
8
|
+
include HTML::Mixin::HtmlHandler
|
9
|
+
include HTML::Mixin::StrongTyping
|
10
|
+
extend HTML::Mixin::StrongTyping
|
11
|
+
|
12
|
+
def initialize(&block)
|
13
|
+
super
|
14
|
+
instance_eval(&block) if block_given?
|
15
|
+
end
|
16
|
+
|
17
|
+
# Adds a Table::Row object as content. The +arg+ is passed as the value
|
18
|
+
# to the Table::Row constructor.
|
19
|
+
#
|
20
|
+
def content=(arg)
|
21
|
+
tr = Table::Row.new(arg)
|
22
|
+
push(tr)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.indent_level
|
26
|
+
@indent_level
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.indent_level=(num)
|
30
|
+
expect(num, Integer)
|
31
|
+
raise ArgumentError, 'indent_level must be >= 0' if num < 0
|
32
|
+
@indent_level = num
|
33
|
+
end
|
34
|
+
|
35
|
+
def []=(index, obj)
|
36
|
+
expect(obj, Table::Row)
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
40
|
+
def push(*args)
|
41
|
+
args.each { |obj| expect(obj, Table::Row) }
|
42
|
+
super
|
43
|
+
end
|
44
|
+
|
45
|
+
def unshift(obj)
|
46
|
+
expect(obj, Table::Row)
|
47
|
+
super
|
48
|
+
end
|
49
|
+
|
50
|
+
alias to_s html
|
51
|
+
alias to_str html
|
52
|
+
end
|
48
53
|
end
|
@@ -0,0 +1,374 @@
|
|
1
|
+
############################################################################
|
2
|
+
# attribute_handler_spec.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 'rspec'
|
8
|
+
require 'html/table'
|
9
|
+
|
10
|
+
RSpec.describe HTML::Mixin::AttributeHandler do
|
11
|
+
before(:all) do
|
12
|
+
NonStandardExtensionWarning.disable
|
13
|
+
end
|
14
|
+
|
15
|
+
before do
|
16
|
+
@table = HTML::Table.new(['foo', 1, 'bar'])
|
17
|
+
end
|
18
|
+
|
19
|
+
after(:all) do
|
20
|
+
NonStandardExtensionWarning.enable
|
21
|
+
end
|
22
|
+
|
23
|
+
example 'abbr_basic' do
|
24
|
+
expect(@table).to respond_to(:abbr)
|
25
|
+
expect(@table).to respond_to(:abbr=)
|
26
|
+
end
|
27
|
+
|
28
|
+
example 'abbr' do
|
29
|
+
expect{ @table.abbr }.not_to raise_error
|
30
|
+
expect(@table.abbr).to be_nil
|
31
|
+
expect{ @table.abbr = 'foo' }.not_to raise_error
|
32
|
+
expect(@table.abbr).to eq('foo')
|
33
|
+
end
|
34
|
+
|
35
|
+
example 'align_basic' do
|
36
|
+
expect(@table).to respond_to(:align)
|
37
|
+
expect(@table).to respond_to(:align=)
|
38
|
+
end
|
39
|
+
|
40
|
+
example 'align' do
|
41
|
+
expect{ @table.align }.not_to raise_error
|
42
|
+
expect(@table.align).to be_nil
|
43
|
+
expect{ @table.align = 'center' }.not_to raise_error
|
44
|
+
expect(@table.align).to eq('center')
|
45
|
+
end
|
46
|
+
|
47
|
+
example 'align_expected_errors' do
|
48
|
+
expect{ @table.align = 'foo' }.to raise_error(ArgumentError)
|
49
|
+
end
|
50
|
+
|
51
|
+
example 'axis' do
|
52
|
+
expect(@table).to respond_to(:axis)
|
53
|
+
expect(@table).to respond_to(:axis=)
|
54
|
+
expect{ @table.axis }.not_to raise_error
|
55
|
+
expect{ @table.axis = 'foo' }.not_to raise_error
|
56
|
+
end
|
57
|
+
|
58
|
+
example 'background_basic' do
|
59
|
+
expect(@table).to respond_to(:background)
|
60
|
+
expect(@table).to respond_to(:background=)
|
61
|
+
end
|
62
|
+
|
63
|
+
example 'background' do
|
64
|
+
expect{ @table.background }.not_to raise_error
|
65
|
+
expect(@table.background).to be_nil
|
66
|
+
expect{ @table.background = 'foo' }.not_to raise_error
|
67
|
+
expect(@table.background).to eq('foo')
|
68
|
+
end
|
69
|
+
|
70
|
+
example 'background_expected_errors' do
|
71
|
+
expect{ @table.background = 1 }.to raise_error(TypeError)
|
72
|
+
end
|
73
|
+
|
74
|
+
example 'bgcolor_basic' do
|
75
|
+
expect(@table).to respond_to(:bgcolor)
|
76
|
+
expect(@table).to respond_to(:bgcolor=)
|
77
|
+
end
|
78
|
+
|
79
|
+
example 'bgcolor' do
|
80
|
+
expect{ @table.bgcolor }.not_to raise_error
|
81
|
+
expect(@table.bgcolor).to be_nil
|
82
|
+
expect{ @table.bgcolor = 'foo' }.not_to raise_error
|
83
|
+
expect(@table.bgcolor).to eq('foo')
|
84
|
+
end
|
85
|
+
|
86
|
+
example 'border_basic' do
|
87
|
+
expect(@table).to respond_to(:border)
|
88
|
+
expect(@table).to respond_to(:border=)
|
89
|
+
end
|
90
|
+
|
91
|
+
example 'border' do
|
92
|
+
expect{ @table.border }.not_to raise_error
|
93
|
+
expect{ @table.border = 2 }.not_to raise_error
|
94
|
+
expect{ @table.border = true }.not_to raise_error
|
95
|
+
expect{ @table.border = false }.not_to raise_error
|
96
|
+
end
|
97
|
+
|
98
|
+
example 'bordercolor_basic' do
|
99
|
+
expect(@table).to respond_to(:bordercolor)
|
100
|
+
expect(@table).to respond_to(:bordercolor=)
|
101
|
+
end
|
102
|
+
|
103
|
+
example 'bordercolor' do
|
104
|
+
expect{ @table.bordercolor }.not_to raise_error
|
105
|
+
expect(@table.bordercolor).to be_nil
|
106
|
+
expect{ @table.bordercolor = 'foo' }.not_to raise_error
|
107
|
+
expect(@table.bordercolor).to eq('foo')
|
108
|
+
end
|
109
|
+
|
110
|
+
example 'bordercolordark_basic' do
|
111
|
+
expect(@table).to respond_to(:bordercolordark)
|
112
|
+
expect(@table).to respond_to(:bordercolordark=)
|
113
|
+
end
|
114
|
+
|
115
|
+
example 'bordercolordark' do
|
116
|
+
expect{ @table.bordercolordark }.not_to raise_error
|
117
|
+
expect(@table.bordercolordark).to be_nil
|
118
|
+
expect{ @table.bordercolordark = 'foo' }.not_to raise_error
|
119
|
+
expect(@table.bordercolordark).to eq('foo')
|
120
|
+
end
|
121
|
+
|
122
|
+
example 'bordercolorlight' do
|
123
|
+
expect(@table).to respond_to(:bordercolorlight)
|
124
|
+
expect(@table).to respond_to(:bordercolorlight=)
|
125
|
+
expect{ @table.bordercolorlight }.not_to raise_error
|
126
|
+
expect{ @table.bordercolorlight = 'foo' }.not_to raise_error
|
127
|
+
end
|
128
|
+
|
129
|
+
example 'cellpadding' do
|
130
|
+
expect(@table).to respond_to(:cellpadding)
|
131
|
+
expect(@table).to respond_to(:cellpadding=)
|
132
|
+
expect{ @table.cellpadding }.not_to raise_error
|
133
|
+
expect{ @table.cellpadding = 1 }.not_to raise_error
|
134
|
+
end
|
135
|
+
|
136
|
+
example 'cellpadding_expected_errors' do
|
137
|
+
expect{ @table.cellpadding = -1 }.to raise_error(ArgumentError)
|
138
|
+
end
|
139
|
+
|
140
|
+
example 'cellspacing' do
|
141
|
+
expect(@table).to respond_to(:cellspacing)
|
142
|
+
expect(@table).to respond_to(:cellspacing=)
|
143
|
+
expect{ @table.cellspacing }.not_to raise_error
|
144
|
+
expect{ @table.cellspacing = 1 }.not_to raise_error
|
145
|
+
end
|
146
|
+
|
147
|
+
example 'cellspacing_expected_errors' do
|
148
|
+
expect{ @table.cellspacing = -1 }.to raise_error(ArgumentError)
|
149
|
+
end
|
150
|
+
|
151
|
+
example 'char' do
|
152
|
+
expect(@table).to respond_to(:char)
|
153
|
+
expect(@table).to respond_to(:char=)
|
154
|
+
expect{ @table.char }.not_to raise_error
|
155
|
+
expect{ @table.char = 'x' }.not_to raise_error
|
156
|
+
end
|
157
|
+
|
158
|
+
example 'char_expected_errors' do
|
159
|
+
expect{ @table.char = 'xx' }.to raise_error(ArgumentError)
|
160
|
+
end
|
161
|
+
|
162
|
+
example 'charoff' do
|
163
|
+
expect(@table).to respond_to(:charoff)
|
164
|
+
expect(@table).to respond_to(:charoff=)
|
165
|
+
expect{ @table.charoff }.not_to raise_error
|
166
|
+
expect{ @table.charoff = 1 }.not_to raise_error
|
167
|
+
end
|
168
|
+
|
169
|
+
example 'charoff_expected_errors' do
|
170
|
+
expect{ @table.charoff = -1 }.to raise_error(ArgumentError)
|
171
|
+
end
|
172
|
+
|
173
|
+
example 'class' do
|
174
|
+
expect(@table).to respond_to(:class_)
|
175
|
+
expect(@table).to respond_to(:class_=)
|
176
|
+
expect{ @table.class_ }.not_to raise_error
|
177
|
+
expect{ @table.class_ = 'myclass' }.not_to raise_error
|
178
|
+
end
|
179
|
+
|
180
|
+
example 'col' do
|
181
|
+
expect(@table).to respond_to(:col)
|
182
|
+
expect(@table).to respond_to(:col=)
|
183
|
+
expect{ @table.col }.not_to raise_error
|
184
|
+
expect{ @table.col = 1 }.not_to raise_error
|
185
|
+
end
|
186
|
+
|
187
|
+
example 'col_expected_errors' do
|
188
|
+
expect{ @table.col = -1 }.to raise_error(ArgumentError)
|
189
|
+
end
|
190
|
+
|
191
|
+
example 'colspan' do
|
192
|
+
expect(@table).to respond_to(:colspan)
|
193
|
+
expect(@table).to respond_to(:colspan=)
|
194
|
+
expect{ @table.colspan }.not_to raise_error
|
195
|
+
expect{ @table.colspan = 1 }.not_to raise_error
|
196
|
+
end
|
197
|
+
|
198
|
+
example 'colspan_expected_errors' do
|
199
|
+
expect{ @table.colspan = -1 }.to raise_error(ArgumentError)
|
200
|
+
end
|
201
|
+
|
202
|
+
example 'configure' do
|
203
|
+
expect(@table).to respond_to(:configure)
|
204
|
+
expect{ @table.configure(0){} }.not_to raise_error
|
205
|
+
expect{ @table.configure(0, 0){} }.not_to raise_error
|
206
|
+
end
|
207
|
+
|
208
|
+
example 'configure_expected_errors' do
|
209
|
+
expect{ @table.configure(0, 0, 0){} }.to raise_error(ArgumentError)
|
210
|
+
end
|
211
|
+
|
212
|
+
example 'content' do
|
213
|
+
expect(@table).to respond_to(:content)
|
214
|
+
expect(@table).to respond_to(:content=)
|
215
|
+
end
|
216
|
+
|
217
|
+
example 'content= with string' do
|
218
|
+
expect{ @table.content = 'foo' }.not_to raise_error
|
219
|
+
end
|
220
|
+
|
221
|
+
example 'content= with numeric' do
|
222
|
+
expect{ @table.content = 123 }.not_to raise_error
|
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
|
231
|
+
expect{ @table.content = HTML::Table::Row.new }.not_to raise_error
|
232
|
+
expect{ @table.content = HTML::Table::Row::Data.new }.not_to raise_error
|
233
|
+
expect{ @table.content = HTML::Table::Row::Header.new }.not_to raise_error
|
234
|
+
end
|
235
|
+
|
236
|
+
example 'content= with other table types' do
|
237
|
+
expect{ @table.content = HTML::Table::Head.create }.not_to raise_error
|
238
|
+
expect{ @table.content = HTML::Table::Foot.create }.not_to raise_error
|
239
|
+
expect{ @table.content = HTML::Table::Body.new }.not_to raise_error
|
240
|
+
end
|
241
|
+
|
242
|
+
example 'frame' do
|
243
|
+
expect(@table).to respond_to(:frame)
|
244
|
+
expect(@table).to respond_to(:frame=)
|
245
|
+
expect{ @table.frame }.not_to raise_error
|
246
|
+
expect{ @table.frame = 'below' }.not_to raise_error
|
247
|
+
end
|
248
|
+
|
249
|
+
example 'frame_expected_errors' do
|
250
|
+
expect{ @table.frame = 'foo' }.to raise_error(ArgumentError)
|
251
|
+
end
|
252
|
+
|
253
|
+
example 'height' do
|
254
|
+
expect(@table).to respond_to(:height)
|
255
|
+
expect(@table).to respond_to(:height=)
|
256
|
+
expect{ @table.height }.not_to raise_error
|
257
|
+
expect{ @table.height = 1 }.not_to raise_error
|
258
|
+
end
|
259
|
+
|
260
|
+
example 'height_expected_errors' do
|
261
|
+
expect{ @table.height = -1 }.to raise_error(ArgumentError)
|
262
|
+
end
|
263
|
+
|
264
|
+
example 'hspace' do
|
265
|
+
expect(@table).to respond_to(:hspace)
|
266
|
+
expect(@table).to respond_to(:hspace=)
|
267
|
+
expect{ @table.hspace }.not_to raise_error
|
268
|
+
expect{ @table.hspace = 1 }.not_to raise_error
|
269
|
+
end
|
270
|
+
|
271
|
+
example 'hspace_expected_errors' do
|
272
|
+
expect{ @table.hspace = -1 }.to raise_error(ArgumentError)
|
273
|
+
end
|
274
|
+
|
275
|
+
example 'nowrap' do
|
276
|
+
expect(@table).to respond_to(:nowrap)
|
277
|
+
expect(@table).to respond_to(:nowrap=)
|
278
|
+
expect{ @table.nowrap }.not_to raise_error
|
279
|
+
expect{ @table.nowrap = false }.not_to raise_error
|
280
|
+
end
|
281
|
+
|
282
|
+
example 'nowrap_expected_errors' do
|
283
|
+
expect{ @table.nowrap = 'foo' }.to raise_error(TypeError)
|
284
|
+
end
|
285
|
+
|
286
|
+
example 'rowspan' do
|
287
|
+
expect(@table).to respond_to(:rowspan)
|
288
|
+
expect(@table).to respond_to(:rowspan=)
|
289
|
+
expect{ @table.rowspan }.not_to raise_error
|
290
|
+
expect{ @table.rowspan = 1 }.not_to raise_error
|
291
|
+
end
|
292
|
+
|
293
|
+
example 'rowspan_expected_errors' do
|
294
|
+
expect{ @table.rowspan = -1 }.to raise_error(ArgumentError)
|
295
|
+
end
|
296
|
+
|
297
|
+
example 'rules' do
|
298
|
+
expect(@table).to respond_to(:rules)
|
299
|
+
expect(@table).to respond_to(:rules=)
|
300
|
+
expect{ @table.rules }.not_to raise_error
|
301
|
+
expect{ @table.rules = 'all' }.not_to raise_error
|
302
|
+
end
|
303
|
+
|
304
|
+
example 'rules_expected_errors' do
|
305
|
+
expect{ @table.rules = 'foo' }.to raise_error(ArgumentError)
|
306
|
+
end
|
307
|
+
|
308
|
+
example 'span' do
|
309
|
+
expect(@table).to respond_to(:span)
|
310
|
+
expect(@table).to respond_to(:span=)
|
311
|
+
expect{ @table.span }.not_to raise_error
|
312
|
+
expect{ @table.span = 1 }.not_to raise_error
|
313
|
+
end
|
314
|
+
|
315
|
+
example 'span_expected_errors' do
|
316
|
+
expect{ @table.span = -1 }.to raise_error(ArgumentError)
|
317
|
+
end
|
318
|
+
|
319
|
+
example 'style' do
|
320
|
+
expect(@table).to respond_to(:style)
|
321
|
+
expect(@table).to respond_to(:style=)
|
322
|
+
expect{ @table.style }.not_to raise_error
|
323
|
+
expect{ @table.style = 'color: blue' }.not_to raise_error
|
324
|
+
end
|
325
|
+
|
326
|
+
example 'summary' do
|
327
|
+
expect(@table).to respond_to(:summary)
|
328
|
+
expect{ @table.summary }.not_to raise_error
|
329
|
+
end
|
330
|
+
|
331
|
+
example 'summary=' do
|
332
|
+
expect(@table).to respond_to(:summary=)
|
333
|
+
expect{ @table.summary = 'foo' }.not_to raise_error
|
334
|
+
expect{ @table.summary = 1 }.not_to raise_error
|
335
|
+
end
|
336
|
+
|
337
|
+
example 'valign' do
|
338
|
+
expect(@table).to respond_to(:valign)
|
339
|
+
expect(@table).to respond_to(:valign=)
|
340
|
+
expect{ @table.valign }.not_to raise_error
|
341
|
+
expect{ @table.valign = 'center' }.not_to raise_error
|
342
|
+
end
|
343
|
+
|
344
|
+
example 'valign_expected_errors' do
|
345
|
+
expect{ @table.valign = 'foo' }.to raise_error(ArgumentError)
|
346
|
+
end
|
347
|
+
|
348
|
+
example 'vspace' do
|
349
|
+
expect(@table).to respond_to(:vspace)
|
350
|
+
expect(@table).to respond_to(:vspace=)
|
351
|
+
expect{ @table.vspace }.not_to raise_error
|
352
|
+
expect{ @table.vspace = 1 }.not_to raise_error
|
353
|
+
end
|
354
|
+
|
355
|
+
example 'vspace_expected_errors' do
|
356
|
+
expect{ @table.vspace = -1 }.to raise_error(ArgumentError)
|
357
|
+
end
|
358
|
+
|
359
|
+
example 'width' do
|
360
|
+
expect(@table).to respond_to(:width)
|
361
|
+
expect(@table).to respond_to(:width=)
|
362
|
+
expect{ @table.width }.not_to raise_error
|
363
|
+
expect{ @table.width = 10 }.not_to raise_error
|
364
|
+
end
|
365
|
+
|
366
|
+
example 'width_with_percent' do
|
367
|
+
expect{ @table.width = '5%' }.not_to raise_error
|
368
|
+
expect(@table.width).to eq('5%')
|
369
|
+
end
|
370
|
+
|
371
|
+
example 'width_expected_errors' do
|
372
|
+
expect{ @table.width = -1 }.to raise_error(ArgumentError)
|
373
|
+
end
|
374
|
+
end
|