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
data/spec/caption_spec.rb
CHANGED
@@ -9,66 +9,75 @@ require 'html/table'
|
|
9
9
|
RSpec.describe HTML::Table::Caption do
|
10
10
|
before do
|
11
11
|
@table = HTML::Table.new
|
12
|
-
@tcaption =
|
12
|
+
@tcaption = described_class.new
|
13
13
|
end
|
14
14
|
|
15
|
-
example
|
16
|
-
expect{
|
17
|
-
expect{ HTML::Table::Caption.new("foo") }.not_to raise_error
|
18
|
-
expect{ HTML::Table::Caption.new(1) }.not_to raise_error
|
19
|
-
expect{ HTML::Table::Caption.new(%w/foo bar baz/) }.not_to raise_error
|
20
|
-
expect{ HTML::Table::Caption.new([1,2,3]) }.not_to raise_error
|
21
|
-
expect{ HTML::Table::Caption.new([[1,2,3],["foo","bar"]]) }.not_to raise_error
|
15
|
+
example 'constructor' do
|
16
|
+
expect{ described_class.new }.not_to raise_error
|
22
17
|
end
|
23
18
|
|
24
|
-
example
|
25
|
-
|
19
|
+
example 'constructor with string' do
|
20
|
+
expect{ described_class.new('foo') }.not_to raise_error
|
21
|
+
end
|
22
|
+
|
23
|
+
example 'constructor with number' do
|
24
|
+
expect{ described_class.new(1) }.not_to raise_error
|
25
|
+
end
|
26
|
+
|
27
|
+
example 'constructor with arrays' 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
|
+
expect{ described_class.new([[1, 2, 3], %w[foo bar]]) }.not_to raise_error
|
31
|
+
end
|
32
|
+
|
33
|
+
example 'basic' do
|
34
|
+
html = '<caption></caption>'
|
26
35
|
expect(@tcaption.html.gsub(/\s+/, '')).to eq(html)
|
27
36
|
end
|
28
37
|
|
29
|
-
example
|
38
|
+
example 'with_attributes' do
|
30
39
|
html = "<caption align='left' valign='top'></caption>"
|
31
|
-
@tcaption.align =
|
32
|
-
@tcaption.valign =
|
40
|
+
@tcaption.align = 'left'
|
41
|
+
@tcaption.valign = 'top'
|
33
42
|
expect(@tcaption.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
|
34
43
|
end
|
35
44
|
|
36
|
-
example
|
45
|
+
example 'configure_not_allowed' do
|
37
46
|
expect{ @tcaption.configure }.to raise_error(NoMethodError)
|
38
47
|
end
|
39
48
|
|
40
|
-
example
|
41
|
-
html =
|
42
|
-
@tcaption.content =
|
49
|
+
example 'add_content' do
|
50
|
+
html = '<caption>hello world</caption>'
|
51
|
+
@tcaption.content = 'hello world'
|
43
52
|
expect(@tcaption.html.gsub(/\s{2,}/, '')).to eq(html)
|
44
53
|
end
|
45
54
|
|
46
|
-
example
|
47
|
-
html =
|
48
|
-
@tcaption.content =
|
55
|
+
example 'add_multiple_content_items' do
|
56
|
+
html = '<caption>hello world</caption>'
|
57
|
+
@tcaption.content = 'hello', ' world'
|
49
58
|
expect(@tcaption.html.gsub(/\s{2,}/, '')).to eq(html)
|
50
59
|
end
|
51
60
|
|
52
|
-
example
|
53
|
-
html =
|
54
|
-
@tcaption =
|
61
|
+
example 'add_content_in_constructor' do
|
62
|
+
html = '<caption>hello world</caption>'
|
63
|
+
@tcaption = described_class.new('hello world')
|
55
64
|
expect(@tcaption.html.gsub(/\s{2,}/, '')).to eq(html)
|
56
65
|
end
|
57
66
|
|
58
|
-
example
|
59
|
-
expect(
|
60
|
-
expect(
|
61
|
-
expect{
|
62
|
-
expect{
|
67
|
+
example 'indent_level' do
|
68
|
+
expect(described_class).to respond_to(:indent_level)
|
69
|
+
expect(described_class).to respond_to(:indent_level=)
|
70
|
+
expect{ described_class.indent_level = 'foo' }.to raise_error(ArgumentTypeError)
|
71
|
+
expect{ described_class.indent_level = 3 }.not_to raise_error
|
63
72
|
end
|
64
73
|
|
65
|
-
example
|
74
|
+
example 'only_row_zero_allowed' do
|
66
75
|
expect{ @table[1] = @tcaption }.to raise_error(ArgumentError)
|
67
76
|
end
|
68
77
|
|
69
|
-
example
|
70
|
-
@table.content =
|
78
|
+
example 'automatically_set_to_row_zero' do
|
79
|
+
@table.content = 'hello', 'world'
|
71
80
|
@table.push(@tcaption)
|
72
|
-
expect(@table[0]).to
|
81
|
+
expect(@table[0]).to be_a(described_class)
|
73
82
|
end
|
74
83
|
end
|
data/spec/colgroup_col_spec.rb
CHANGED
@@ -11,24 +11,24 @@ RSpec.describe HTML::Table::ColGroup::Col do
|
|
11
11
|
@col = described_class.new
|
12
12
|
end
|
13
13
|
|
14
|
-
example
|
15
|
-
html =
|
14
|
+
example 'basic' do
|
15
|
+
html = '<col>'
|
16
16
|
expect(@col.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
|
17
17
|
end
|
18
18
|
|
19
|
-
example
|
19
|
+
example 'no_configure' do
|
20
20
|
expect{ @col.configure }.to raise_error(NoMethodError)
|
21
21
|
end
|
22
22
|
|
23
|
-
example
|
23
|
+
example 'no_content_allowed' do
|
24
24
|
expect{ @col.content }.to raise_error(NoMethodError)
|
25
|
-
expect{ @col.content =
|
25
|
+
expect{ @col.content = 'foo' }.to raise_error(NoMethodError)
|
26
26
|
end
|
27
27
|
|
28
|
-
example
|
28
|
+
example 'indent_level' do
|
29
29
|
expect(described_class).to respond_to(:indent_level)
|
30
30
|
expect(described_class).to respond_to(:indent_level=)
|
31
|
-
expect{ described_class.indent_level =
|
31
|
+
expect{ described_class.indent_level = 'foo' }.to raise_error(ArgumentTypeError)
|
32
32
|
expect{ described_class.indent_level = 6 }.not_to raise_error
|
33
33
|
end
|
34
34
|
end
|
data/spec/colgroup_spec.rb
CHANGED
@@ -8,76 +8,90 @@ require 'html/table'
|
|
8
8
|
|
9
9
|
RSpec.describe HTML::Table::ColGroup do
|
10
10
|
before do
|
11
|
-
@cgroup =
|
11
|
+
@cgroup = described_class.new
|
12
12
|
@col = HTML::Table::ColGroup::Col.new
|
13
13
|
end
|
14
14
|
|
15
|
-
example
|
16
|
-
expect{
|
17
|
-
expect{
|
18
|
-
expect{
|
15
|
+
example 'constructor' do
|
16
|
+
expect{ described_class.new }.not_to raise_error
|
17
|
+
expect{ described_class.new(@col) }.not_to raise_error
|
18
|
+
expect{ described_class.new('foo') }.to raise_error(ArgumentTypeError)
|
19
19
|
end
|
20
20
|
|
21
|
-
example
|
22
|
-
html =
|
21
|
+
example 'basic' do
|
22
|
+
html = '<colgroup></colgroup>'
|
23
23
|
expect(@cgroup.html.gsub(/\s+/, '')).to eq(html)
|
24
24
|
end
|
25
25
|
|
26
|
-
example
|
26
|
+
example 'with attributes' do
|
27
27
|
html = "<colgroup align='center' width='20%'></colgroup>"
|
28
|
-
@cgroup.align =
|
29
|
-
@cgroup.width =
|
28
|
+
@cgroup.align = 'center'
|
29
|
+
@cgroup.width = '20%'
|
30
30
|
expect(@cgroup.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
|
31
31
|
end
|
32
32
|
|
33
|
-
example
|
34
|
-
html =
|
33
|
+
example 'push single col element' do
|
34
|
+
html = '<colgroup><col></colgroup>'
|
35
35
|
@cgroup.push(@col)
|
36
36
|
expect(@cgroup.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
|
37
37
|
end
|
38
38
|
|
39
|
-
example
|
40
|
-
expect{ @cgroup[0] =
|
39
|
+
example 'index assignment constraints' do
|
40
|
+
expect{ @cgroup[0] = 'foo' }.to raise_error(ArgumentTypeError)
|
41
41
|
expect{ @cgroup[0] = 1 }.to raise_error(ArgumentTypeError)
|
42
42
|
expect{ @cgroup[1] = HTML::Table::Row.new }.to raise_error(ArgumentTypeError)
|
43
43
|
expect{ @cgroup[0] = HTML::Table::ColGroup::Col.new }.not_to raise_error
|
44
44
|
end
|
45
45
|
|
46
|
-
example
|
47
|
-
expect{ @cgroup.push(7) }.to raise_error(
|
48
|
-
expect{ @cgroup.push(
|
49
|
-
expect{ @cgroup.push(HTML::Table::Row.new) }.to raise_error(
|
46
|
+
example 'push constraints' do
|
47
|
+
expect{ @cgroup.push(7) }.to raise_error(ArgumentTypeError)
|
48
|
+
expect{ @cgroup.push('hello') }.to raise_error(ArgumentTypeError)
|
49
|
+
expect{ @cgroup.push(HTML::Table::Row.new) }.to raise_error(ArgumentTypeError)
|
50
50
|
expect{ @cgroup.push(HTML::Table::ColGroup::Col.new) }.not_to raise_error
|
51
51
|
end
|
52
52
|
|
53
|
-
example
|
54
|
-
expect{ @cgroup << 7 }.to raise_error(
|
55
|
-
expect{ @cgroup <<
|
56
|
-
expect{ @cgroup << HTML::Table::Row.new }.to raise_error(
|
53
|
+
example 'double arrow constraints' do
|
54
|
+
expect{ @cgroup << 7 }.to raise_error(ArgumentTypeError)
|
55
|
+
expect{ @cgroup << 'hello' }.to raise_error(ArgumentTypeError)
|
56
|
+
expect{ @cgroup << HTML::Table::Row.new }.to raise_error(ArgumentTypeError)
|
57
57
|
expect{ @cgroup << HTML::Table::ColGroup::Col.new }.not_to raise_error
|
58
58
|
end
|
59
59
|
|
60
|
-
example
|
61
|
-
expect{ @cgroup.
|
60
|
+
example 'unshift constraints' do
|
61
|
+
expect{ @cgroup.unshift(7) }.to raise_error(ArgumentTypeError)
|
62
|
+
expect{ @cgroup.unshift('hello') }.to raise_error(ArgumentTypeError)
|
63
|
+
expect{ @cgroup.unshift(HTML::Table::Row.new) }.to raise_error(ArgumentTypeError)
|
64
|
+
expect{ @cgroup.unshift(HTML::Table::ColGroup::Col.new) }.not_to raise_error
|
62
65
|
end
|
63
66
|
|
64
|
-
example
|
67
|
+
example 'configure error' do
|
68
|
+
expect{ @cgroup.configure(0, 0){} }.to raise_error(ArgumentError)
|
69
|
+
end
|
70
|
+
|
71
|
+
example 'content error' do
|
65
72
|
expect{ @cgroup.content }.to raise_error(NoMethodError)
|
66
73
|
expect{ @cgroup.content = 'blah' }.to raise_error(NoMethodError)
|
67
74
|
end
|
68
75
|
|
69
|
-
example
|
70
|
-
expect(
|
71
|
-
expect(
|
72
|
-
expect{
|
73
|
-
expect{
|
76
|
+
example 'indent_level' do
|
77
|
+
expect(described_class).to respond_to(:indent_level)
|
78
|
+
expect(described_class).to respond_to(:indent_level=)
|
79
|
+
expect{ described_class.indent_level = 'foo' }.to raise_error(ArgumentTypeError)
|
80
|
+
expect{ described_class.indent_level = 6 }.not_to raise_error
|
81
|
+
end
|
82
|
+
|
83
|
+
example 'end_tags? basic functionality' do
|
84
|
+
expect(described_class).to respond_to(:end_tags?)
|
85
|
+
expect(described_class.end_tags?).to be(true)
|
86
|
+
end
|
87
|
+
|
88
|
+
example 'end_tags= basic functionality' do
|
89
|
+
expect(described_class).to respond_to(:end_tags=)
|
90
|
+
expect{ described_class.end_tags = true }.not_to raise_error
|
74
91
|
end
|
75
92
|
|
76
|
-
example
|
77
|
-
expect
|
78
|
-
expect
|
79
|
-
expect{ HTML::Table::ColGroup.end_tags = "foo" }.to raise_error(ArgumentTypeError)
|
80
|
-
expect{ HTML::Table::ColGroup.end_tags = 1 }.to raise_error(ArgumentTypeError)
|
81
|
-
expect{ HTML::Table::ColGroup.end_tags = true }.not_to raise_error
|
93
|
+
example 'end_tags= raises an error if an invalid type is assigned' do
|
94
|
+
expect{ described_class.end_tags = 'foo' }.to raise_error(ArgumentTypeError)
|
95
|
+
expect{ described_class.end_tags = 1 }.to raise_error(ArgumentTypeError)
|
82
96
|
end
|
83
97
|
end
|
data/spec/data_spec.rb
CHANGED
@@ -11,21 +11,30 @@ RSpec.describe HTML::Table::Row::Data do
|
|
11
11
|
@tdata = described_class.new
|
12
12
|
end
|
13
13
|
|
14
|
-
example
|
14
|
+
example 'constructor' do
|
15
15
|
expect{ described_class.new }.not_to raise_error
|
16
|
-
|
16
|
+
end
|
17
|
+
|
18
|
+
example 'constructor with string' do
|
19
|
+
expect{ described_class.new('foo') }.not_to raise_error
|
20
|
+
end
|
21
|
+
|
22
|
+
example 'constructor with numeric' do
|
17
23
|
expect{ described_class.new(1) }.not_to raise_error
|
18
|
-
expect{ described_class.new(%w/foo bar baz/) }.not_to raise_error
|
19
|
-
expect{ described_class.new([1,2,3]) }.not_to raise_error
|
20
|
-
expect{ described_class.new([[1,2,3],["foo","bar"]]) }.not_to raise_error
|
21
24
|
end
|
22
25
|
|
23
|
-
example
|
24
|
-
|
26
|
+
example 'constructor with arrays' do
|
27
|
+
expect{ described_class.new(%w[foo bar baz]) }.not_to raise_error
|
28
|
+
expect{ described_class.new([1, 2, 3]) }.not_to raise_error
|
29
|
+
expect{ described_class.new([[1, 2, 3], %w[foo bar]]) }.not_to raise_error
|
30
|
+
end
|
31
|
+
|
32
|
+
example 'basic' do
|
33
|
+
html = '<td></td>'
|
25
34
|
expect(@tdata.html.gsub(/\s+/, '')).to eq(html)
|
26
35
|
end
|
27
36
|
|
28
|
-
example
|
37
|
+
example 'with_attributes' do
|
29
38
|
html = "<td align='left' width=3 nowrap></td>"
|
30
39
|
@tdata.align = 'left'
|
31
40
|
@tdata.width = 3
|
@@ -33,40 +42,47 @@ RSpec.describe HTML::Table::Row::Data do
|
|
33
42
|
expect(@tdata.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
|
34
43
|
end
|
35
44
|
|
36
|
-
example
|
45
|
+
example 'configure_not_allowed' do
|
37
46
|
expect{ @tdata.configure }.to raise_error(NoMethodError)
|
38
47
|
end
|
39
48
|
|
40
|
-
example
|
41
|
-
html =
|
42
|
-
@tdata.content =
|
49
|
+
example 'add_content' do
|
50
|
+
html = '<td>hello world</td>'
|
51
|
+
@tdata.content = 'hello world'
|
43
52
|
expect(@tdata.html.gsub(/\s{2,}/, '')).to eq(html)
|
44
53
|
end
|
45
54
|
|
46
|
-
example
|
47
|
-
html =
|
48
|
-
td = described_class.new(
|
55
|
+
example 'add_content_in_constructor' do
|
56
|
+
html = '<td>hello world</td>'
|
57
|
+
td = described_class.new('hello world')
|
49
58
|
expect(td.html.gsub(/\s{2,}/, '')).to eq(html)
|
50
59
|
end
|
51
60
|
|
52
|
-
example
|
53
|
-
html =
|
54
|
-
@tdata.content =
|
61
|
+
example 'add_multiple_content_items' do
|
62
|
+
html = '<td>hello world</td>'
|
63
|
+
@tdata.content = 'hello', ' world'
|
55
64
|
expect(@tdata.html.gsub(/\s{2,}/, '')).to eq(html)
|
56
65
|
end
|
57
66
|
|
58
|
-
example
|
67
|
+
example 'indent_level' do
|
59
68
|
expect(described_class).to respond_to(:indent_level)
|
60
69
|
expect(described_class).to respond_to(:indent_level=)
|
61
|
-
expect{ described_class.indent_level =
|
70
|
+
expect{ described_class.indent_level = 'foo' }.to raise_error(ArgumentTypeError)
|
62
71
|
expect{ described_class.indent_level = 6 }.not_to raise_error
|
63
72
|
end
|
64
73
|
|
65
|
-
example
|
74
|
+
example 'end_tags? basic functionality' do
|
66
75
|
expect(described_class).to respond_to(:end_tags?)
|
76
|
+
expect(described_class.end_tags?).to be(true)
|
77
|
+
end
|
78
|
+
|
79
|
+
example 'end_tags= basic functionality' do
|
67
80
|
expect(described_class).to respond_to(:end_tags=)
|
68
|
-
expect{ described_class.end_tags = "foo" }.to raise_error(ArgumentTypeError)
|
69
|
-
expect{ described_class.end_tags = 1 }.to raise_error(ArgumentTypeError)
|
70
81
|
expect{ described_class.end_tags = true }.not_to raise_error
|
71
82
|
end
|
83
|
+
|
84
|
+
example 'end_tags= raises an error on an invalid value' do
|
85
|
+
expect{ described_class.end_tags = 'foo' }.to raise_error(ArgumentTypeError)
|
86
|
+
expect{ described_class.end_tags = 1 }.to raise_error(ArgumentTypeError)
|
87
|
+
end
|
72
88
|
end
|
data/spec/foot_spec.rb
CHANGED
@@ -8,97 +8,109 @@
|
|
8
8
|
require 'rspec'
|
9
9
|
require 'html/table'
|
10
10
|
|
11
|
-
class HTML::Table::Foot
|
12
|
-
private
|
13
|
-
def refresh
|
14
|
-
@@foot = nil
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
11
|
RSpec.describe HTML::Table::Foot do
|
19
12
|
before do
|
20
|
-
@table = HTML::Table.new
|
21
13
|
@tfoot = described_class.create
|
22
14
|
end
|
23
15
|
|
24
|
-
|
25
|
-
|
16
|
+
after do
|
17
|
+
described_class.instance_variable_set(:@instance, nil)
|
26
18
|
end
|
27
19
|
|
28
|
-
example
|
20
|
+
example 'constructor' do
|
29
21
|
expect{ described_class.create }.not_to raise_error
|
30
|
-
|
22
|
+
end
|
23
|
+
|
24
|
+
example 'constructor with string' do
|
25
|
+
expect{ described_class.create('foo') }.not_to raise_error
|
26
|
+
end
|
27
|
+
|
28
|
+
example 'constructor with numeric' do
|
31
29
|
expect{ described_class.create(1) }.not_to raise_error
|
32
|
-
expect{ described_class.create(%w/foo bar baz/) }.not_to raise_error
|
33
|
-
expect{ described_class.create([1,2,3]) }.not_to raise_error
|
34
|
-
expect{ described_class.create([[1,2,3], ["foo","bar"]]) }.not_to raise_error
|
35
30
|
end
|
36
31
|
|
37
|
-
example
|
38
|
-
|
32
|
+
example 'constructor with arrays' do
|
33
|
+
expect{ described_class.create(%w[foo bar baz]) }.not_to raise_error
|
34
|
+
expect{ described_class.create([1, 2, 3]) }.not_to raise_error
|
35
|
+
expect{ described_class.create([[1, 2, 3], %w[foo bar]]) }.not_to raise_error
|
36
|
+
end
|
37
|
+
|
38
|
+
example 'basic' do
|
39
|
+
html = '<tfoot></tfoot>'
|
39
40
|
expect(@tfoot.html.gsub(/\s{2,}|\n/, '')).to eq(html)
|
40
41
|
end
|
41
42
|
|
42
|
-
example
|
43
|
+
example 'end_tags? basic functionality' do
|
43
44
|
expect(described_class).to respond_to(:end_tags?)
|
44
|
-
expect(described_class).to
|
45
|
+
expect(described_class.end_tags?).to be(true)
|
45
46
|
expect{ described_class.end_tags? }.not_to raise_error
|
47
|
+
end
|
48
|
+
|
49
|
+
example 'end_tags= basic functionality' do
|
50
|
+
expect(described_class).to respond_to(:end_tags=)
|
46
51
|
expect{ described_class.end_tags = true }.not_to raise_error
|
47
52
|
end
|
48
53
|
|
49
|
-
example
|
50
|
-
expect{ described_class.end_tags =
|
54
|
+
example 'end_tags raises an error on an invalid type' do
|
55
|
+
expect{ described_class.end_tags = 'foo' }.to raise_error(ArgumentTypeError)
|
51
56
|
end
|
52
57
|
|
53
|
-
example
|
58
|
+
example 'with attributes' do
|
54
59
|
html = "<tfoot align='left' char='x'></tfoot>"
|
55
|
-
@tfoot.align =
|
60
|
+
@tfoot.align = 'left'
|
56
61
|
@tfoot.char = 'x'
|
57
62
|
expect(@tfoot.html.gsub(/\s{2,}|\n/, '')).to eq(html)
|
58
63
|
end
|
59
64
|
|
60
|
-
example
|
61
|
-
html =
|
62
|
-
@tfoot.push
|
65
|
+
example 'push single row' do
|
66
|
+
html = '<tfoot><tr><td>test</td></tr></tfoot>'
|
67
|
+
@tfoot.push(HTML::Table::Row.new{ |r| r.content = 'test' })
|
63
68
|
expect(@tfoot.html.gsub(/\s{2,}|\n/, '')).to eq(html)
|
64
69
|
end
|
65
70
|
|
66
|
-
example
|
67
|
-
html =
|
68
|
-
r1 = Table::Row.new{|r| r.content =
|
69
|
-
r2 = Table::Row.new{|r| r.content =
|
71
|
+
example 'push multiple rows' do
|
72
|
+
html = '<tfoot><tr><td>test</td></tr><tr><td>foo</td></tr></tfoot>'
|
73
|
+
r1 = HTML::Table::Row.new{ |r| r.content = 'test' }
|
74
|
+
r2 = HTML::Table::Row.new{ |r| r.content = 'foo' }
|
70
75
|
@tfoot.push r1, r2
|
71
76
|
expect(@tfoot.html.gsub(/\s{2,}|\n/, '')).to eq(html)
|
72
77
|
end
|
73
78
|
|
74
|
-
example
|
75
|
-
html =
|
76
|
-
@tfoot.content =
|
79
|
+
example 'add content directly' do
|
80
|
+
html = '<tfoot><tr><td>hello</td><td>world</td></tr></tfoot>'
|
81
|
+
@tfoot.content = 'hello', 'world'
|
77
82
|
expect(@tfoot.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
|
78
83
|
end
|
79
84
|
|
80
|
-
example
|
81
|
-
html =
|
82
|
-
|
83
|
-
@tfoot = described_class.create([
|
85
|
+
example 'add content in constructor' do
|
86
|
+
html = '<tfoot><tr><td>hello</td><td>world</td></tr></tfoot>'
|
87
|
+
described_class.instance_variable_set(:@instance, nil)
|
88
|
+
@tfoot = described_class.create(%w[hello world])
|
84
89
|
expect(@tfoot.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
|
85
90
|
end
|
86
91
|
|
87
|
-
example
|
92
|
+
example 'configure column' do
|
88
93
|
html = "<tfoot><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
|
89
|
-
html +=
|
90
|
-
@tfoot.content =
|
91
|
-
@tfoot.configure(0,1)
|
94
|
+
html += '</td></tr></tfoot>'
|
95
|
+
@tfoot.content = 'hello', 'world'
|
96
|
+
@tfoot.configure(0, 1) do |data|
|
92
97
|
data.abbr = 'test'
|
93
98
|
data.width = 3
|
94
99
|
data.nowrap = true
|
95
|
-
|
100
|
+
end
|
96
101
|
expect(@tfoot.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
|
97
102
|
end
|
98
103
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
104
|
+
# rubocop:disable RSpec/IdenticalEqualityAssertion
|
105
|
+
example 'new not allowed' do
|
106
|
+
expect{ described_class.new }.to raise_error(NoMethodError)
|
107
|
+
end
|
108
|
+
|
109
|
+
example 'additional calls to constructor do nothing since class is a singleton' do
|
110
|
+
expect(described_class.create).to eq(described_class.create)
|
111
|
+
expect(described_class.instance).to eq(described_class.instance)
|
112
|
+
expect(described_class.instance.object_id).to eq(described_class.instance.object_id)
|
113
|
+
expect(described_class.create.object_id).to eq(described_class.create.object_id)
|
103
114
|
end
|
115
|
+
# rubocop:enable RSpec/IdenticalEqualityAssertion
|
104
116
|
end
|