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/head_spec.rb CHANGED
@@ -8,94 +8,109 @@
8
8
  require 'rspec'
9
9
  require 'html/table'
10
10
 
11
- #####################################################################
12
- # Ensure that a fresh instance of described_class is used between tests
13
- # by calling 'refresh' in the 'teardown' method.
14
- #####################################################################
15
- class HTML::Table::Head
16
- private
17
- def refresh
18
- @@head = nil
19
- end
20
- end
21
-
22
11
  RSpec.describe HTML::Table::Head do
23
12
  before do
24
- @table = HTML::Table.new
25
13
  @thead = described_class.create
26
14
  end
27
15
 
28
- example "constructor" do
16
+ after do
17
+ described_class.instance_variable_set(:@instance, nil)
18
+ end
19
+
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 = "<thead></thead>"
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 = '<thead></thead>'
39
40
  expect(@thead.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
- expect{ described_class.end_tags = "foo" }.to raise_error(HTML::Mixin::StrongTyping::ArgumentTypeError)
48
52
  end
49
53
 
50
- example "with_attributes" do
54
+ example 'end_tags= does not allow invalid types' do
55
+ expect{ described_class.end_tags = 'foo' }.to raise_error(ArgumentTypeError)
56
+ end
57
+
58
+ example 'with attributes' do
51
59
  html = "<thead align='left' char='x'></thead>"
52
- @thead.align = "left"
60
+ @thead.align = 'left'
53
61
  @thead.char = 'x'
54
62
  expect(@thead.html.gsub(/\s{2,}|\n/, '')).to eq(html)
55
63
  end
56
64
 
57
- example "push_single_row" do
58
- html = "<thead><tr><td>test</td></tr></thead>"
59
- @thead.push HTML::Table::Row.new{|r| r.content = "test"}
65
+ example 'push single row' do
66
+ html = '<thead><tr><td>test</td></tr></thead>'
67
+ @thead.push(HTML::Table::Row.new{ |r| r.content = 'test' })
60
68
  expect(@thead.html.gsub(/\s{2,}|\n/, '')).to eq(html)
61
69
  end
62
70
 
63
- example "push_multiple_rows" do
64
- html = "<thead><tr><td>test</td></tr><tr><td>foo</td></tr></thead>"
65
- r1 = HTML::Table::Row.new("test")
66
- r2 = HTML::Table::Row.new("foo")
71
+ example 'push multiple rows' do
72
+ html = '<thead><tr><td>test</td></tr><tr><td>foo</td></tr></thead>'
73
+ r1 = HTML::Table::Row.new('test')
74
+ r2 = HTML::Table::Row.new('foo')
67
75
  @thead.push(r1, r2)
68
76
  expect(@thead.html.gsub(/\s{2,}|\n/, '')).to eq(html)
69
77
  end
70
78
 
71
- example "add_content_directly" do
72
- html = "<thead><tr><td>hello</td><td>world</td></tr></thead>"
73
- @thead.content = "hello","world"
79
+ example 'add content directly' do
80
+ html = '<thead><tr><td>hello</td><td>world</td></tr></thead>'
81
+ @thead.content = 'hello', 'world'
74
82
  expect(@thead.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
75
83
  end
76
84
 
77
- example "add_content_in_constructor" do
78
- html = "<thead><tr><td>hello</td><td>world</td></tr></thead>"
79
- @thead.send(:refresh)
80
- @thead = described_class.create(["hello","world"])
85
+ example 'add content in constructor' do
86
+ html = '<thead><tr><td>hello</td><td>world</td></tr></thead>'
87
+ described_class.instance_variable_set(:@instance, nil)
88
+ @thead = described_class.create(%w[hello world])
81
89
  expect(@thead.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
82
90
  end
83
91
 
84
- example "configure_column" do
92
+ example 'configure column' do
85
93
  html = "<thead><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
86
- html += "</td></tr></thead>"
87
- @thead.content = "hello","world"
88
- @thead.configure(0,1){ |d|
94
+ html += '</td></tr></thead>'
95
+ @thead.content = 'hello', 'world'
96
+ @thead.configure(0, 1) do |d|
89
97
  d.abbr = 'test'
90
98
  d.width = 3
91
99
  d.nowrap = true
92
- }
100
+ end
93
101
  expect(@thead.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
94
102
  end
95
103
 
96
- after do
97
- @table = nil
98
- @thead.send(:refresh)
99
- @thead = 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)
100
114
  end
115
+ # rubocop:enable RSpec/IdenticalEqualityAssertion
101
116
  end
data/spec/header_spec.rb CHANGED
@@ -11,21 +11,30 @@ RSpec.describe HTML::Table::Row::Header do
11
11
  @theader = described_class.new
12
12
  end
13
13
 
14
- example "basic" do
15
- html = "<th></th>"
14
+ example 'basic' do
15
+ html = '<th></th>'
16
16
  expect(@theader.html.gsub(/\s+/, '')).to eq(html)
17
17
  end
18
18
 
19
- example "constructor" do
19
+ example 'constructor' do
20
20
  expect{ described_class.new }.not_to raise_error
21
- expect{ described_class.new("foo") }.not_to raise_error
21
+ end
22
+
23
+ example 'constructor with string' do
24
+ expect{ described_class.new('foo') }.not_to raise_error
25
+ end
26
+
27
+ example 'constructor with numeric' do
22
28
  expect{ described_class.new(1) }.not_to raise_error
23
- expect{ described_class.new(%w/foo bar baz/) }.not_to raise_error
24
- expect{ described_class.new([1,2,3]) }.not_to raise_error
25
- expect{ described_class.new([[1,2,3],["foo","bar"]]) }.not_to raise_error
26
29
  end
27
30
 
28
- example "with_attributes" do
31
+ example 'constructor with arrays' do
32
+ expect{ described_class.new(%w[foo bar baz]) }.not_to raise_error
33
+ expect{ described_class.new([1, 2, 3]) }.not_to raise_error
34
+ expect{ described_class.new([[1, 2, 3], %w[foo bar]]) }.not_to raise_error
35
+ end
36
+
37
+ example 'with_attributes' do
29
38
  html = "<th align='left' colspan=3 nowrap></th>"
30
39
  @theader.align = 'left'
31
40
  @theader.colspan = 3
@@ -33,39 +42,43 @@ RSpec.describe HTML::Table::Row::Header do
33
42
  expect(@theader.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{ @theader.configure }.to raise_error(NoMethodError)
38
47
  end
39
48
 
40
- example "add_content" do
41
- html = "<th>hello world</th>"
42
- @theader.content = "hello world"
49
+ example 'add_content' do
50
+ html = '<th>hello world</th>'
51
+ @theader.content = 'hello world'
43
52
  expect(@theader.html.gsub(/\s{2,}/, '')).to eq(html)
44
53
  end
45
54
 
46
- example "add_multiple_content_items" do
47
- html = "<th>hello world</th>"
48
- @theader.content = "hello"," world"
55
+ example 'add_multiple_content_items' do
56
+ html = '<th>hello world</th>'
57
+ @theader.content = 'hello', ' world'
49
58
  expect(@theader.html.gsub(/\s{2,}/, '')).to eq(html)
50
59
  end
51
60
 
52
- example "add_content_in_constructor" do
53
- html = "<th>hello world</th>"
54
- @theader = described_class.new("hello world")
61
+ example 'add_content_in_constructor' do
62
+ html = '<th>hello world</th>'
63
+ @theader = described_class.new('hello world')
55
64
  expect(@theader.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= only accepts valid types' do
67
80
  expect(described_class).to respond_to(:end_tags=)
68
- expect{ described_class.end_tags = "foo" }.to raise_error(ArgumentTypeError)
81
+ expect{ described_class.end_tags = 'foo' }.to raise_error(ArgumentTypeError)
69
82
  expect{ described_class.end_tags = 1 }.to raise_error(ArgumentTypeError)
70
83
  expect{ described_class.end_tags = true }.not_to raise_error
71
84
  end
@@ -9,24 +9,27 @@ require 'html/table'
9
9
 
10
10
  RSpec.describe HTML::Mixin::HtmlHandler do
11
11
  before do
12
- @table = HTML::Table.new(["foo",1,"bar"])
12
+ @table = HTML::Table.new(['foo', 1, 'bar'])
13
13
  end
14
14
 
15
- example "html" do
15
+ example 'html basic functionality' do
16
16
  expect(@table).to respond_to(:html)
17
17
  expect{ @table.html }.not_to raise_error
18
- expect{ @table.html = "foo" }.to raise_error(NoMethodError)
19
- expect( @table.html).to be_kind_of(String)
20
- expect( @table.html.length > 0).to eq(true)
18
+ expect(@table.html).to be_a(String)
19
+ expect(!@table.html.empty?).to be(true)
21
20
  end
22
21
 
23
- example "modify_html" do
22
+ example 'there is no html= method' do
23
+ expect{ @table.html = 'foo' }.to raise_error(NoMethodError)
24
+ end
25
+
26
+ example 'modify_html' do
24
27
  expect{ @table.send(:modify_html) }.to raise_error(ArgumentError)
25
- expect{ @table.send(:modify_html,"nowrap") }.not_to raise_error
26
- expect{ @table.send(:modify_html,"align","top") }.not_to raise_error
27
- expect{
28
- @table.send(:modify_html,"align","top")
29
- @table.send(:modify_html,"align","top")
30
- }.not_to raise_error
28
+ expect{ @table.send(:modify_html, 'nowrap') }.not_to raise_error
29
+ expect{ @table.send(:modify_html, 'align', 'top') }.not_to raise_error
30
+ expect do
31
+ @table.send(:modify_html, 'align', 'top')
32
+ @table.send(:modify_html, 'align', 'top')
33
+ end.not_to raise_error
31
34
  end
32
35
  end
data/spec/row_spec.rb CHANGED
@@ -1,136 +1,163 @@
1
1
  ############################################
2
2
  # row_spec.rb
3
3
  #
4
- # Specs for the Table::Row class.
4
+ # Specs for the HTML::Table::Row class.
5
5
  ############################################
6
6
  require 'rspec'
7
7
  require 'html/table'
8
- include HTML
9
8
 
10
9
  RSpec.describe HTML::Table::Row do
11
10
  before do
12
11
  @trow = described_class.new
13
12
  end
14
13
 
15
- example "constructor" do
16
- expect{ Table::Row.new }.not_to raise_error
17
- expect{ Table::Row.new("foo") }.not_to raise_error
18
- expect{ Table::Row.new(1) }.not_to raise_error
19
- expect{ Table::Row.new([1,2,3]) }.not_to raise_error
20
- expect{ Table::Row.new([[1,2,3],["foo","bar"]]) }.not_to raise_error
14
+ example 'constructor' do
15
+ expect{ described_class.new }.not_to raise_error
21
16
  end
22
17
 
23
- example "basic" do
24
- html = "<tr></tr>"
18
+ example 'constructor with string argument' do
19
+ expect{ described_class.new('foo') }.not_to raise_error
20
+ end
21
+
22
+ example 'constructor with numeric argument' do
23
+ expect{ described_class.new(1) }.not_to raise_error
24
+ end
25
+
26
+ example 'constructor with array arguments' do
27
+ expect{ described_class.new([1, 2, 3]) }.not_to raise_error
28
+ expect{ described_class.new([[1, 2, 3], %w[foo bar]]) }.not_to raise_error
29
+ end
30
+
31
+ example 'basic' do
32
+ html = '<tr></tr>'
25
33
  expect(@trow.html.gsub(/\s+/, '')).to eq(html)
26
34
  end
27
35
 
28
- example "header" do
36
+ example 'header' do
29
37
  expect(@trow).to respond_to(:header?)
30
38
  expect(@trow).to respond_to(:header=)
31
39
  expect{ @trow.header? }.not_to raise_error
32
40
  expect{ @trow.header = true }.not_to raise_error
33
41
  end
34
42
 
35
- example "with_attributes" do
43
+ example 'with attributes' do
36
44
  html = "<tr align='center'></tr>"
37
- @trow.align = "center"
45
+ @trow.align = 'center'
38
46
  expect(@trow.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
39
47
  end
40
48
 
41
- example "index_assignment_constraints" do
42
- expect{ @trow[0] = "foo" }.to raise_error(ArgumentTypeError)
49
+ example 'index assignment allows valid types' do
50
+ expect{ @trow[0] = HTML::Table::Row::Data.new }.not_to raise_error
51
+ expect{ @trow[0] = HTML::Table::Row::Header.new }.not_to raise_error
52
+ end
53
+
54
+ example 'index assignment raises an error for invalid types' do
55
+ expect{ @trow[0] = 'foo' }.to raise_error(ArgumentTypeError)
43
56
  expect{ @trow[0] = 1 }.to raise_error(ArgumentTypeError)
44
- expect{ @trow[0] = Table::Caption.new }.to raise_error(ArgumentTypeError)
45
- expect{ @trow[0] = Table::Row::Data.new }.not_to raise_error
46
- expect{ @trow[0] = Table::Row::Header.new }.not_to raise_error
57
+ expect{ @trow[0] = HTML::Table::Caption.new }.to raise_error(ArgumentTypeError)
47
58
  end
48
59
 
49
- example "push_constraints" do
50
- expect{ @trow.push(Table::Caption.new) }.to raise_error(ArgumentTypeError)
51
- expect{ @trow.push(nil) }.to raise_error(ArgumentTypeError)
52
- expect{ @trow.push("test") }.not_to raise_error
60
+ example 'push allows valid types' do
61
+ expect{ @trow.push('test') }.not_to raise_error
53
62
  expect{ @trow.push(7) }.not_to raise_error
54
- expect{ @trow.push(Table::Row::Data.new) }.not_to raise_error
55
- expect{ @trow.push(Table::Row::Header.new) }.not_to raise_error
63
+ expect{ @trow.push(HTML::Table::Row::Data.new) }.not_to raise_error
64
+ expect{ @trow.push(HTML::Table::Row::Header.new) }.not_to raise_error
65
+ end
66
+
67
+ example 'push raises an error for invalid types' do
68
+ expect{ @trow.push(HTML::Table::Caption.new) }.to raise_error(ArgumentTypeError)
69
+ expect{ @trow.push(nil) }.to raise_error(ArgumentTypeError)
56
70
  end
57
71
 
58
- example "double_arrow_constraints" do
59
- expect{ @trow << Table::Caption.new }.to raise_error(ArgumentTypeError)
60
- expect{ @trow << "test" }.not_to raise_error
61
- expect{ @trow << "test" << "foo" }.not_to raise_error
62
- expect{ @trow << Table::Row::Data.new }.not_to raise_error
63
- expect{ @trow << Table::Row::Header.new }.not_to raise_error
72
+ example 'double arrow allows valid types' do
73
+ expect{ @trow << 'test' }.not_to raise_error
74
+ expect{ @trow << 'test' << 'foo' }.not_to raise_error
75
+ expect{ @trow << HTML::Table::Row::Data.new }.not_to raise_error
76
+ expect{ @trow << HTML::Table::Row::Header.new }.not_to raise_error
64
77
  end
65
78
 
66
- example "header_in_constructor" do
67
- expect{ @trow = Table::Row.new('test', true) }.not_to raise_error
68
- html = "<tr><th>test</th></tr>"
79
+ example 'double arrow raises an error for invalid types' do
80
+ expect{ @trow << HTML::Table::Caption.new }.to raise_error(ArgumentTypeError)
81
+ end
82
+
83
+ example 'header in constructor' do
84
+ expect{ @trow = described_class.new('test', true) }.not_to raise_error
85
+ html = '<tr><th>test</th></tr>'
69
86
  expect(@trow.html.gsub(/\s+/, '')).to eq(html)
70
87
  end
71
88
 
72
- example "push_single_data_element" do
73
- html = "<tr><td>hello</td></tr>"
74
- @trow.push Table::Row::Data.new{ |d| d.content = "hello" }
89
+ example 'push single data element' do
90
+ html = '<tr><td>hello</td></tr>'
91
+ @trow.push(HTML::Table::Row::Data.new{ |d| d.content = 'hello' })
75
92
  expect(@trow.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
76
93
  end
77
94
 
78
- example "push_multiple_data_element" do
79
- html = "<tr><td>hello</td><td>world</td></tr>"
80
- d1 = Table::Row::Data.new{ |d| d.content = "hello" }
81
- d2 = Table::Row::Data.new{ |d| d.content = "world" }
95
+ example 'push multiple data element' do
96
+ html = '<tr><td>hello</td><td>world</td></tr>'
97
+ d1 = HTML::Table::Row::Data.new{ |d| d.content = 'hello' }
98
+ d2 = HTML::Table::Row::Data.new{ |d| d.content = 'world' }
82
99
  @trow.push d1, d2
83
100
  expect(@trow.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
84
101
  end
85
102
 
86
- example "add_content_directly" do
87
- html = "<tr><td>hello</td><td>world</td></tr>"
88
- @trow.content = "hello","world"
103
+ example 'add content directly' do
104
+ html = '<tr><td>hello</td><td>world</td></tr>'
105
+ @trow.content = 'hello', 'world'
89
106
  expect(@trow.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
90
107
  end
91
108
 
92
- example "add_content_in_constructor" do
93
- html = "<tr><td>hello</td><td>world</td></tr>"
94
- @trow = Table::Row.new(%w/hello world/)
109
+ example 'add content in constructor' do
110
+ html = '<tr><td>hello</td><td>world</td></tr>'
111
+ @trow = described_class.new(%w[hello world])
95
112
  expect(@trow.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
96
113
  end
97
114
 
98
- example "configure_column" do
115
+ example 'configure column' do
99
116
  html = "<tr><td>hello</td><td abbr='test' width=3 nowrap>world</td></tr>"
100
- @trow.content = "hello","world"
101
- @trow.configure(1){ |d|
117
+ @trow.content = 'hello', 'world'
118
+ @trow.configure(1) do |d|
102
119
  d.abbr = 'test'
103
120
  d.width = 3
104
121
  d.nowrap = true
105
- }
122
+ end
106
123
  expect(@trow.html.gsub(/\s{2,}|\n+/, '')).to eq(html)
107
124
  end
108
125
 
109
- example "unshift_constraints" do
110
- expect{ @trow.unshift(Table::Caption.new) }.to raise_error(ArgumentTypeError)
126
+ example 'unshift does not allow invalid types' do
127
+ expect{ @trow.unshift(HTML::Table::Caption.new) }.to raise_error(ArgumentTypeError)
111
128
  expect{ @trow.unshift(nil) }.to raise_error(ArgumentTypeError)
112
- expect{ @trow.unshift("test") }.not_to raise_error
129
+ end
130
+
131
+ example 'unshift allows proper types' do
132
+ expect{ @trow.unshift('test') }.not_to raise_error
113
133
  expect{ @trow.unshift(7) }.not_to raise_error
114
- expect{ @trow.unshift(Table::Row::Data.new) }.not_to raise_error
115
- expect{ @trow.unshift(Table::Row::Header.new) }.not_to raise_error
134
+ expect{ @trow.unshift(HTML::Table::Row::Data.new) }.not_to raise_error
135
+ expect{ @trow.unshift(HTML::Table::Row::Header.new) }.not_to raise_error
136
+ end
137
+
138
+ example 'configure error' do
139
+ expect{ @trow.configure(0, 0){} }.to raise_error(ArgumentError)
140
+ end
141
+
142
+ example 'indent_level' do
143
+ expect(described_class).to respond_to(:indent_level)
144
+ expect(described_class).to respond_to(:indent_level=)
145
+ expect{ described_class.indent_level = 'foo' }.to raise_error(ArgumentTypeError)
146
+ expect{ described_class.indent_level = 3 }.not_to raise_error
116
147
  end
117
148
 
118
- example "configure_error" do
119
- expect{ @trow.configure(0,0){ }.to raise_error(ArgumentError) }
149
+ example 'end_tags?' do
150
+ expect(described_class).to respond_to(:end_tags?)
151
+ expect(described_class.end_tags?).to be(true)
120
152
  end
121
153
 
122
- example "indent_level" do
123
- expect(Table::Row).to respond_to(:indent_level)
124
- expect(Table::Row).to respond_to(:indent_level=)
125
- expect{ Table::Row.indent_level = "foo" }.to raise_error(ArgumentTypeError)
126
- expect{ Table::Row.indent_level = 3 }.not_to raise_error
154
+ example 'end_tags= basic functionality' do
155
+ expect(described_class).to respond_to(:end_tags=)
156
+ expect{ described_class.end_tags = true }.not_to raise_error
127
157
  end
128
158
 
129
- example "end_tags" do
130
- expect(Table::Row).to respond_to(:end_tags?)
131
- expect(Table::Row).to respond_to(:end_tags=)
132
- expect{ Table::Row.end_tags = "foo" }.to raise_error(ArgumentTypeError)
133
- expect{ Table::Row.end_tags = 1 }.to raise_error(ArgumentTypeError)
134
- expect{ Table::Row.end_tags = true }.not_to raise_error
159
+ example 'end_tags= rejects invalid values' do
160
+ expect{ described_class.end_tags = 'foo' }.to raise_error(ArgumentTypeError)
161
+ expect{ described_class.end_tags = 1 }.to raise_error(ArgumentTypeError)
135
162
  end
136
163
  end