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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/{CHANGES.rdoc → CHANGES.md} +73 -69
  4. data/Gemfile +2 -7
  5. data/{MANIFEST.rdoc → MANIFEST.md} +15 -15
  6. data/{README.rdoc → README.md} +80 -71
  7. data/Rakefile +7 -2
  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 +13 -8
  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 +57 -53
  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 +94 -80
  39. data/spec/body_spec.rb +54 -37
  40. data/spec/caption_spec.rb +41 -32
  41. data/spec/colgroup_col_spec.rb +7 -7
  42. data/spec/colgroup_spec.rb +50 -36
  43. data/spec/data_spec.rb +39 -23
  44. data/spec/foot_spec.rb +58 -46
  45. data/spec/head_spec.rb +62 -47
  46. data/spec/header_spec.rb +35 -22
  47. data/spec/html_handler_spec.rb +15 -12
  48. data/spec/row_spec.rb +95 -68
  49. data/spec/table_spec.rb +65 -31
  50. data/spec/tablesection_spec.rb +13 -13
  51. data/spec/tag_handler_spec.rb +13 -13
  52. data.tar.gz.sig +0 -0
  53. metadata +103 -78
  54. metadata.gz.sig +0 -0
  55. data/doc/attributes.rdoc +0 -143
  56. data/doc/table.rdoc +0 -156
  57. data/doc/table_body.rdoc +0 -9
  58. data/doc/table_caption.rdoc +0 -9
  59. data/doc/table_colgroup.rdoc +0 -8
  60. data/doc/table_colgroup_col.rdoc +0 -9
  61. data/doc/table_content.rdoc +0 -15
  62. data/doc/table_foot.rdoc +0 -8
  63. data/doc/table_head.rdoc +0 -11
  64. data/doc/table_row.rdoc +0 -105
  65. data/doc/table_row_data.rdoc +0 -92
  66. 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 = HTML::Table::Caption.new
12
+ @tcaption = described_class.new
13
13
  end
14
14
 
15
- example "constructor" do
16
- expect{ HTML::Table::Caption.new }.not_to raise_error
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 "basic" do
25
- html = "<caption></caption>"
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 "with_attributes" do
38
+ example 'with_attributes' do
30
39
  html = "<caption align='left' valign='top'></caption>"
31
- @tcaption.align = "left"
32
- @tcaption.valign = "top"
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 "configure_not_allowed" do
45
+ example 'configure_not_allowed' do
37
46
  expect{ @tcaption.configure }.to raise_error(NoMethodError)
38
47
  end
39
48
 
40
- example "add_content" do
41
- html = "<caption>hello world</caption>"
42
- @tcaption.content = "hello world"
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 "add_multiple_content_items" do
47
- html = "<caption>hello world</caption>"
48
- @tcaption.content = "hello"," world"
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 "add_content_in_constructor" do
53
- html = "<caption>hello world</caption>"
54
- @tcaption = HTML::Table::Caption.new("hello world")
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 "indent_level" do
59
- expect(HTML::Table::Caption).to respond_to(:indent_level)
60
- expect(HTML::Table::Caption).to respond_to(:indent_level=)
61
- expect{ HTML::Table::Caption.indent_level = "foo" }.to raise_error(ArgumentTypeError)
62
- expect{ HTML::Table::Caption.indent_level = 3 }.not_to raise_error
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 "only_row_zero_allowed" do
74
+ example 'only_row_zero_allowed' do
66
75
  expect{ @table[1] = @tcaption }.to raise_error(ArgumentError)
67
76
  end
68
77
 
69
- example "automatically_set_to_row_zero" do
70
- @table.content = "hello","world"
78
+ example 'automatically_set_to_row_zero' do
79
+ @table.content = 'hello', 'world'
71
80
  @table.push(@tcaption)
72
- expect(@table[0]).to be_kind_of(HTML::Table::Caption)
81
+ expect(@table[0]).to be_a(described_class)
73
82
  end
74
83
  end
@@ -11,24 +11,24 @@ RSpec.describe HTML::Table::ColGroup::Col do
11
11
  @col = described_class.new
12
12
  end
13
13
 
14
- example "basic" do
15
- html = "<col>"
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 "no_configure" do
19
+ example 'no_configure' do
20
20
  expect{ @col.configure }.to raise_error(NoMethodError)
21
21
  end
22
22
 
23
- example "no_content_allowed" do
23
+ example 'no_content_allowed' do
24
24
  expect{ @col.content }.to raise_error(NoMethodError)
25
- expect{ @col.content = "foo" }.to raise_error(NoMethodError)
25
+ expect{ @col.content = 'foo' }.to raise_error(NoMethodError)
26
26
  end
27
27
 
28
- example "indent_level" do
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 = "foo" }.to raise_error(ArgumentTypeError)
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
@@ -8,76 +8,90 @@ require 'html/table'
8
8
 
9
9
  RSpec.describe HTML::Table::ColGroup do
10
10
  before do
11
- @cgroup = HTML::Table::ColGroup.new
11
+ @cgroup = described_class.new
12
12
  @col = HTML::Table::ColGroup::Col.new
13
13
  end
14
14
 
15
- example "constructor" do
16
- expect{ HTML::Table::ColGroup.new }.not_to raise_error
17
- expect{ HTML::Table::ColGroup.new(@col) }.not_to raise_error
18
- expect{ HTML::Table::ColGroup.new("foo") }.to raise_error(TypeError)
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 "basic" do
22
- html = "<colgroup></colgroup>"
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 "with_attributes" do
26
+ example 'with attributes' do
27
27
  html = "<colgroup align='center' width='20%'></colgroup>"
28
- @cgroup.align = "center"
29
- @cgroup.width = "20%"
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 "push_single_col_element" do
34
- html = "<colgroup><col></colgroup>"
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 "index_assignment_constraints" do
40
- expect{ @cgroup[0] = "foo" }.to raise_error(ArgumentTypeError)
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 "push_constraints" do
47
- expect{ @cgroup.push(7) }.to raise_error(TypeError)
48
- expect{ @cgroup.push("hello") }.to raise_error(TypeError)
49
- expect{ @cgroup.push(HTML::Table::Row.new) }.to raise_error(TypeError)
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 "double_arrow_constraints" do
54
- expect{ @cgroup << 7 }.to raise_error(TypeError)
55
- expect{ @cgroup << "hello" }.to raise_error(TypeError)
56
- expect{ @cgroup << HTML::Table::Row.new }.to raise_error(TypeError)
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 "configure_error" do
61
- expect{ @cgroup.configure(0,0){ }.to raise_error(ArgumentError) }
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 "content_error" do
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 "indent_level" do
70
- expect(HTML::Table::ColGroup).to respond_to(:indent_level)
71
- expect(HTML::Table::ColGroup).to respond_to(:indent_level=)
72
- expect{ HTML::Table::ColGroup.indent_level = "foo" }.to raise_error(ArgumentTypeError)
73
- expect{ HTML::Table::ColGroup.indent_level = 6 }.not_to raise_error
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 "end_tags" do
77
- expect(HTML::Table::ColGroup).to respond_to(:end_tags?)
78
- expect(HTML::Table::ColGroup).to respond_to(:end_tags=)
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 "constructor" do
14
+ example 'constructor' do
15
15
  expect{ described_class.new }.not_to raise_error
16
- expect{ described_class.new("foo") }.not_to raise_error
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 "basic" do
24
- html = "<td></td>"
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 "with_attributes" do
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 "configure_not_allowed" do
45
+ example 'configure_not_allowed' do
37
46
  expect{ @tdata.configure }.to raise_error(NoMethodError)
38
47
  end
39
48
 
40
- example "add_content" do
41
- html = "<td>hello world</td>"
42
- @tdata.content = "hello world"
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 "add_content_in_constructor" do
47
- html = "<td>hello world</td>"
48
- td = described_class.new("hello world")
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 "add_multiple_content_items" do
53
- html = "<td>hello world</td>"
54
- @tdata.content = "hello"," world"
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 "indent_level" do
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 = "foo" }.to raise_error(ArgumentTypeError)
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 "end_tags" do
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
- example "new_not_allowed" do
25
- expect{ described_class.new }.to raise_error(NoMethodError)
16
+ after do
17
+ described_class.instance_variable_set(:@instance, nil)
26
18
  end
27
19
 
28
- example "constructor" do
20
+ example 'constructor' do
29
21
  expect{ described_class.create }.not_to raise_error
30
- expect{ described_class.create("foo") }.not_to raise_error
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 "basic" do
38
- html = "<tfoot></tfoot>"
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 "end_tags" do
43
+ example 'end_tags? basic functionality' do
43
44
  expect(described_class).to respond_to(:end_tags?)
44
- expect(described_class).to respond_to(:end_tags=)
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 "end_tags_expected_errors" do
50
- expect{ described_class.end_tags = "foo" }.to raise_error(HTML::Mixin::StrongTyping::ArgumentTypeError)
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 "with_attributes" do
58
+ example 'with attributes' do
54
59
  html = "<tfoot align='left' char='x'></tfoot>"
55
- @tfoot.align = "left"
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 "push_single_row" do
61
- html = "<tfoot><tr><td>test</td></tr></tfoot>"
62
- @tfoot.push Table::Row.new{|r| r.content = "test"}
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 "push_multiple_rows" do
67
- html = "<tfoot><tr><td>test</td></tr><tr><td>foo</td></tr></tfoot>"
68
- r1 = Table::Row.new{|r| r.content = "test"}
69
- r2 = Table::Row.new{|r| r.content = "foo"}
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 "add_content_directly" do
75
- html = "<tfoot><tr><td>hello</td><td>world</td></tr></tfoot>"
76
- @tfoot.content = "hello","world"
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 "add_content_in_constructor" do
81
- html = "<tfoot><tr><td>hello</td><td>world</td></tr></tfoot>"
82
- @tfoot.send(:refresh)
83
- @tfoot = described_class.create(["hello","world"])
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 "configure_column" do
92
+ example 'configure column' do
88
93
  html = "<tfoot><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
89
- html += "</td></tr></tfoot>"
90
- @tfoot.content = "hello","world"
91
- @tfoot.configure(0,1){ |data|
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
- after do
100
- @table = nil
101
- @tfoot.send(:refresh)
102
- @tfoot = nil
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