html-table 1.5.2 → 1.7.0
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.tar.gz.sig +0 -0
- data/{CHANGES → CHANGES.rdoc} +22 -0
- data/Gemfile +7 -0
- data/LICENSE +177 -0
- data/MANIFEST.rdoc +57 -0
- data/README.rdoc +132 -0
- data/Rakefile +117 -146
- data/doc/table.rdoc +2 -4
- data/html-table.gemspec +6 -7
- data/lib/html/caption.rb +2 -2
- data/lib/html/col.rb +2 -2
- data/lib/html/colgroup.rb +4 -4
- data/lib/html/content.rb +2 -2
- data/lib/html/data.rb +2 -2
- data/lib/html/header.rb +2 -2
- data/lib/html/mixin/attribute_handler.rb +407 -0
- data/lib/html/mixin/html_handler.rb +124 -0
- data/lib/html/mixin/strongtyping.rb +17 -0
- data/lib/html/mixin/tag_handler.rb +125 -0
- data/lib/html/row.rb +2 -2
- data/lib/html/table.rb +7 -7
- data/lib/html/tablesection.rb +2 -2
- data/spec/attribute_handler_spec.rb +360 -0
- data/spec/body_spec.rb +81 -0
- data/spec/caption_spec.rb +74 -0
- data/spec/colgroup_col_spec.rb +34 -0
- data/spec/colgroup_spec.rb +83 -0
- data/spec/data_spec.rb +72 -0
- data/spec/foot_spec.rb +104 -0
- data/spec/head_spec.rb +101 -0
- data/spec/header_spec.rb +72 -0
- data/spec/html_handler_spec.rb +32 -0
- data/spec/row_spec.rb +136 -0
- data/spec/table_spec.rb +152 -0
- data/spec/tablesection_spec.rb +36 -0
- data/spec/tag_handler_spec.rb +85 -0
- metadata +55 -66
- metadata.gz.sig +0 -0
- data/MANIFEST +0 -59
- data/README +0 -132
- data/lib/html/attribute_handler.rb +0 -403
- data/lib/html/html_handler.rb +0 -120
- data/lib/html/tag_handler.rb +0 -121
- 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
@@ -0,0 +1,124 @@
|
|
1
|
+
module HTML
|
2
|
+
module Mixin
|
3
|
+
module HtmlHandler
|
4
|
+
|
5
|
+
$upper = false
|
6
|
+
|
7
|
+
# Used on HTML attributes. It creates proper HTML text based on the argument
|
8
|
+
# type. A string looks like "attr='text'", a number looks like "attr=1",
|
9
|
+
# while a true value simply looks like "attr" (no equal sign).
|
10
|
+
#--
|
11
|
+
# This is private method.
|
12
|
+
#
|
13
|
+
def modify_html(attribute,arg=nil)
|
14
|
+
if @html_begin.scan(/\b#{attribute}\b/).empty?
|
15
|
+
if arg.kind_of?(Integer)
|
16
|
+
@html_begin << " #{attribute}=#{arg}"
|
17
|
+
elsif arg.kind_of?(TrueClass)
|
18
|
+
@html_begin << " #{attribute}"
|
19
|
+
else
|
20
|
+
@html_begin << " #{attribute}='#{arg}'"
|
21
|
+
end
|
22
|
+
else
|
23
|
+
if arg.kind_of?(Integer)
|
24
|
+
@html_begin.gsub!(/#{attribute}=\d+/,"#{attribute}=#{arg}")
|
25
|
+
elsif arg.kind_of?(FalseClass)
|
26
|
+
@html_begin.gsub!(/#{attribute}/,'')
|
27
|
+
else
|
28
|
+
@html_begin.gsub!(/#{attribute}=['\w\.]+/,"#{attribute}='#{arg}'")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns the HTML text for the current object. Indentation and end tag
|
34
|
+
# options are optional, based on the settings of the classes themselves.
|
35
|
+
#
|
36
|
+
# If +formatting+ is false, then formatting and whitespace is not applied
|
37
|
+
# and you will get a single, very long string. Note that case is still
|
38
|
+
# honored.
|
39
|
+
#
|
40
|
+
def html(formatting = true)
|
41
|
+
if self.class.respond_to?(:html_case)
|
42
|
+
$upper = true if self.class.html_case == "upper"
|
43
|
+
end
|
44
|
+
|
45
|
+
if $upper
|
46
|
+
@html_begin.upcase!
|
47
|
+
@html_end.upcase!
|
48
|
+
end
|
49
|
+
|
50
|
+
ilevel = 0
|
51
|
+
|
52
|
+
if formatting && self.class.respond_to?(:indent_level)
|
53
|
+
ilevel = self.class.indent_level
|
54
|
+
end
|
55
|
+
|
56
|
+
html = ' ' * ilevel + @html_begin[0..-1]
|
57
|
+
len = html.length
|
58
|
+
html[len,len] = '>'
|
59
|
+
|
60
|
+
if self.kind_of?(Array)
|
61
|
+
if formatting
|
62
|
+
html << self.map{ |e| "\n" + e.html(formatting).to_s }.join
|
63
|
+
else
|
64
|
+
html << self.map{ |e| e.html(formatting).to_s }.join
|
65
|
+
end
|
66
|
+
else
|
67
|
+
html << @html_body
|
68
|
+
end
|
69
|
+
|
70
|
+
#####################################################################
|
71
|
+
# Add end tags, or not, depending on whether the class supports the
|
72
|
+
# end_tags class method. Those that don't have an end_tags class
|
73
|
+
# method necessarily means that the end tag must be included.
|
74
|
+
#
|
75
|
+
# The Table.global_end_tags method overrides the individual class
|
76
|
+
# preferences with regards to end tags.
|
77
|
+
#####################################################################
|
78
|
+
if self.kind_of?(Array)
|
79
|
+
if HTML::Table.global_end_tags?
|
80
|
+
if self.class.respond_to?(:end_tags?)
|
81
|
+
if formatting
|
82
|
+
if self.class.end_tags?
|
83
|
+
html << "\n" + (' ' * ilevel) + @html_end
|
84
|
+
end
|
85
|
+
else
|
86
|
+
html << (' ' * ilevel) + @html_end if self.class.end_tags?
|
87
|
+
end
|
88
|
+
else
|
89
|
+
if formatting
|
90
|
+
html << "\n" + (' ' * ilevel) + @html_end
|
91
|
+
else
|
92
|
+
html << (' ' * ilevel) + @html_end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
else
|
96
|
+
unless self.class.respond_to?(:end_tags?)
|
97
|
+
if formatting
|
98
|
+
html << "\n" + (' ' * ilevel) + @html_end
|
99
|
+
else
|
100
|
+
html << (' ' * ilevel) + @html_end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
else
|
105
|
+
if HTML::Table.global_end_tags?
|
106
|
+
if self.class.respond_to?(:end_tags?)
|
107
|
+
html << @html_end if self.class.end_tags?
|
108
|
+
else
|
109
|
+
html << @html_end
|
110
|
+
end
|
111
|
+
else
|
112
|
+
unless self.class.respond_to?(:end_tags?)
|
113
|
+
html << @html_end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
return html
|
119
|
+
end
|
120
|
+
|
121
|
+
private :modify_html
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# A pure-ruby replacement for strongtyping gem
|
2
|
+
|
3
|
+
module HTML
|
4
|
+
module Mixin
|
5
|
+
module StrongTyping
|
6
|
+
class ArgumentTypeError < ArgumentError; end
|
7
|
+
|
8
|
+
def expect(arg, allowed_types)
|
9
|
+
return true if Array(allowed_types).any? do |klass|
|
10
|
+
arg.kind_of?(klass)
|
11
|
+
end
|
12
|
+
|
13
|
+
raise ArgumentTypeError.new("#{arg} must be of type #{allowed_types}")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
###################################################################
|
2
|
+
# tag_handler.rb
|
3
|
+
#
|
4
|
+
# Module for handling standard html physical tags (<b>, <i>, etc).
|
5
|
+
# Only used for Table::Content objects, which are in turn used by
|
6
|
+
# Table::Row::Data, Table::Row::Header and Table::Caption.
|
7
|
+
###################################################################
|
8
|
+
module HTML
|
9
|
+
module Mixin
|
10
|
+
module TagHandler
|
11
|
+
def bold(bool = nil)
|
12
|
+
@bold ||= nil
|
13
|
+
self.bold = bool if bool
|
14
|
+
@bold
|
15
|
+
end
|
16
|
+
|
17
|
+
def bold=(bool)
|
18
|
+
handle_physical_tag('b', bool)
|
19
|
+
@bold = bool
|
20
|
+
end
|
21
|
+
|
22
|
+
def big(bool = nil)
|
23
|
+
@big ||= nil
|
24
|
+
self.big = bool if bool
|
25
|
+
@big
|
26
|
+
end
|
27
|
+
|
28
|
+
def big=(bool)
|
29
|
+
handle_physical_tag('big', bool)
|
30
|
+
@big = bool
|
31
|
+
end
|
32
|
+
|
33
|
+
def blink(bool = nil)
|
34
|
+
@blink ||= nil
|
35
|
+
self.blink = bool if bool
|
36
|
+
@blink
|
37
|
+
end
|
38
|
+
|
39
|
+
def blink=(bool)
|
40
|
+
warn BlinkWarning, "The 'blink' tag is very annoying. Please reconsider."
|
41
|
+
handle_physical_tag('blink', bool)
|
42
|
+
@blink = bool
|
43
|
+
end
|
44
|
+
|
45
|
+
def italic(bool = nil)
|
46
|
+
@italic ||= nil
|
47
|
+
self.italic = bool if bool
|
48
|
+
@italic
|
49
|
+
end
|
50
|
+
|
51
|
+
def italic=(bool)
|
52
|
+
handle_physical_tag('i', bool)
|
53
|
+
@italic = bool
|
54
|
+
end
|
55
|
+
|
56
|
+
def strike(bool = nil)
|
57
|
+
@strike ||= nil
|
58
|
+
self.strike = bool if bool
|
59
|
+
@strike
|
60
|
+
end
|
61
|
+
|
62
|
+
def strike=(bool)
|
63
|
+
handle_physical_tag('strike', bool)
|
64
|
+
@strike = bool
|
65
|
+
end
|
66
|
+
|
67
|
+
def sub(bool = nil)
|
68
|
+
@sub ||= nil
|
69
|
+
self.sub = bool if bool
|
70
|
+
@sub
|
71
|
+
end
|
72
|
+
|
73
|
+
def sub=(bool)
|
74
|
+
handle_physical_tag('sub', bool)
|
75
|
+
@sub = bool
|
76
|
+
end
|
77
|
+
|
78
|
+
def sup(bool = nil)
|
79
|
+
@sup ||= nil
|
80
|
+
self.sup = bool if bool
|
81
|
+
@sup
|
82
|
+
end
|
83
|
+
|
84
|
+
def sup=(bool)
|
85
|
+
handle_physical_tag('sup', bool)
|
86
|
+
@sup = bool
|
87
|
+
end
|
88
|
+
|
89
|
+
def tt(bool = nil)
|
90
|
+
@tt ||= nil
|
91
|
+
self.tt = bool if bool
|
92
|
+
@tt
|
93
|
+
end
|
94
|
+
|
95
|
+
def tt=(bool)
|
96
|
+
handle_physical_tag('tt', bool)
|
97
|
+
@tt = bool
|
98
|
+
end
|
99
|
+
|
100
|
+
def underline(bool = nil)
|
101
|
+
@underline ||= nil
|
102
|
+
self.underline = bool if bool
|
103
|
+
@underline
|
104
|
+
end
|
105
|
+
|
106
|
+
def underline=(bool)
|
107
|
+
handle_physical_tag('u', bool)
|
108
|
+
@bool = bool
|
109
|
+
end
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
def handle_physical_tag(tag, bool)
|
114
|
+
begin_tag = "<#{tag}>"
|
115
|
+
end_tag = "</#{tag}>"
|
116
|
+
|
117
|
+
if bool
|
118
|
+
self.replace(begin_tag << self << end_tag)
|
119
|
+
else
|
120
|
+
self.replace(self.gsub(/#{begin_tag}|#{end_tag}/,''))
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
data/lib/html/row.rb
CHANGED
data/lib/html/table.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require_relative 'attribute_handler'
|
2
|
-
require_relative 'html_handler'
|
3
|
-
|
1
|
+
require_relative 'mixin/attribute_handler'
|
2
|
+
require_relative 'mixin/html_handler'
|
3
|
+
require_relative 'mixin/strongtyping'
|
4
4
|
require 'structured_warnings'
|
5
|
-
include StrongTyping
|
5
|
+
include HTML::Mixin::StrongTyping
|
6
6
|
|
7
7
|
# Warning raised if a non-standard extension is used.
|
8
8
|
class NonStandardExtensionWarning < StructuredWarnings::StandardWarning; end
|
@@ -16,11 +16,11 @@ module HTML
|
|
16
16
|
# The Table class encapsulates methods associated with an html table
|
17
17
|
# element. It is the "outermost" class of the html-table classes.
|
18
18
|
class Table < Array
|
19
|
-
include AttributeHandler
|
20
|
-
include HtmlHandler
|
19
|
+
include HTML::Mixin::AttributeHandler
|
20
|
+
include HTML::Mixin::HtmlHandler
|
21
21
|
|
22
22
|
# The version of the html-table library
|
23
|
-
VERSION = '1.
|
23
|
+
VERSION = '1.7.0'.freeze
|
24
24
|
|
25
25
|
# The indentation level for the <table> and </table> tags
|
26
26
|
@indent_level = 0
|
data/lib/html/tablesection.rb
CHANGED
@@ -2,8 +2,8 @@ module HTML
|
|
2
2
|
# Superclass for THEAD, TBODY, TFOOT
|
3
3
|
#
|
4
4
|
class Table::TableSection < Array
|
5
|
-
include AttributeHandler
|
6
|
-
include HtmlHandler
|
5
|
+
include HTML::Mixin::AttributeHandler
|
6
|
+
include HTML::Mixin::HtmlHandler
|
7
7
|
|
8
8
|
def initialize(&block)
|
9
9
|
instance_eval(&block) if block_given?
|
@@ -0,0 +1,360 @@
|
|
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
|
+
example "abbr_basic" do
|
20
|
+
expect(@table).to respond_to(:abbr)
|
21
|
+
expect(@table).to respond_to(:abbr=)
|
22
|
+
end
|
23
|
+
|
24
|
+
example "abbr" do
|
25
|
+
expect{ @table.abbr }.not_to raise_error
|
26
|
+
expect(@table.abbr).to be_nil
|
27
|
+
expect{ @table.abbr = 'foo' }.not_to raise_error
|
28
|
+
expect( @table.abbr).to eq('foo')
|
29
|
+
end
|
30
|
+
|
31
|
+
example "align_basic" do
|
32
|
+
expect(@table).to respond_to(:align)
|
33
|
+
expect(@table).to respond_to(:align=)
|
34
|
+
end
|
35
|
+
|
36
|
+
example "align" do
|
37
|
+
expect{ @table.align }.not_to raise_error
|
38
|
+
expect(@table.align).to be_nil
|
39
|
+
expect{ @table.align = 'center' }.not_to raise_error
|
40
|
+
expect( @table.align).to eq('center')
|
41
|
+
end
|
42
|
+
|
43
|
+
example "align_expected_errors" do
|
44
|
+
expect{ @table.align = 'foo' }.to raise_error(ArgumentError)
|
45
|
+
end
|
46
|
+
|
47
|
+
example "axis" do
|
48
|
+
expect(@table).to respond_to(:axis)
|
49
|
+
expect(@table).to respond_to(:axis=)
|
50
|
+
expect{ @table.axis }.not_to raise_error
|
51
|
+
expect{ @table.axis = 'foo' }.not_to raise_error
|
52
|
+
end
|
53
|
+
|
54
|
+
example "background_basic" do
|
55
|
+
expect(@table).to respond_to(:background)
|
56
|
+
expect(@table).to respond_to(:background=)
|
57
|
+
end
|
58
|
+
|
59
|
+
example "background" do
|
60
|
+
expect{ @table.background }.not_to raise_error
|
61
|
+
expect(@table.background).to be_nil
|
62
|
+
expect{ @table.background = 'foo' }.not_to raise_error
|
63
|
+
expect( @table.background).to eq('foo')
|
64
|
+
end
|
65
|
+
|
66
|
+
example "background_expected_errors" do
|
67
|
+
expect{ @table.background = 1 }.to raise_error(TypeError)
|
68
|
+
end
|
69
|
+
|
70
|
+
example "bgcolor_basic" do
|
71
|
+
expect(@table).to respond_to(:bgcolor)
|
72
|
+
expect(@table).to respond_to(:bgcolor=)
|
73
|
+
end
|
74
|
+
|
75
|
+
example "bgcolor" do
|
76
|
+
expect{ @table.bgcolor }.not_to raise_error
|
77
|
+
expect(@table.bgcolor).to be_nil
|
78
|
+
expect{ @table.bgcolor = 'foo' }.not_to raise_error
|
79
|
+
expect( @table.bgcolor).to eq('foo')
|
80
|
+
end
|
81
|
+
|
82
|
+
example "border_basic" do
|
83
|
+
expect(@table).to respond_to(:border)
|
84
|
+
expect(@table).to respond_to(:border=)
|
85
|
+
end
|
86
|
+
|
87
|
+
example "border" do
|
88
|
+
expect{ @table.border }.not_to raise_error
|
89
|
+
expect{ @table.border = 2 }.not_to raise_error
|
90
|
+
expect{ @table.border = true }.not_to raise_error
|
91
|
+
expect{ @table.border = false }.not_to raise_error
|
92
|
+
end
|
93
|
+
|
94
|
+
example "bordercolor_basic" do
|
95
|
+
expect(@table).to respond_to(:bordercolor)
|
96
|
+
expect(@table).to respond_to(:bordercolor=)
|
97
|
+
end
|
98
|
+
|
99
|
+
example "bordercolor" do
|
100
|
+
expect{ @table.bordercolor }.not_to raise_error
|
101
|
+
expect(@table.bordercolor).to be_nil
|
102
|
+
expect{ @table.bordercolor = 'foo' }.not_to raise_error
|
103
|
+
expect( @table.bordercolor).to eq('foo')
|
104
|
+
end
|
105
|
+
|
106
|
+
example "bordercolordark_basic" do
|
107
|
+
expect(@table).to respond_to(:bordercolordark)
|
108
|
+
expect(@table).to respond_to(:bordercolordark=)
|
109
|
+
end
|
110
|
+
|
111
|
+
example "bordercolordark" do
|
112
|
+
expect{ @table.bordercolordark }.not_to raise_error
|
113
|
+
expect(@table.bordercolordark).to be_nil
|
114
|
+
expect{ @table.bordercolordark = 'foo' }.not_to raise_error
|
115
|
+
expect( @table.bordercolordark).to eq('foo')
|
116
|
+
end
|
117
|
+
|
118
|
+
example "bordercolorlight" do
|
119
|
+
expect(@table).to respond_to(:bordercolorlight)
|
120
|
+
expect(@table).to respond_to(:bordercolorlight=)
|
121
|
+
expect{ @table.bordercolorlight }.not_to raise_error
|
122
|
+
expect{ @table.bordercolorlight = 'foo' }.not_to raise_error
|
123
|
+
end
|
124
|
+
|
125
|
+
example "cellpadding" do
|
126
|
+
expect(@table).to respond_to(:cellpadding)
|
127
|
+
expect(@table).to respond_to(:cellpadding=)
|
128
|
+
expect{ @table.cellpadding }.not_to raise_error
|
129
|
+
expect{ @table.cellpadding = 1 }.not_to raise_error
|
130
|
+
end
|
131
|
+
|
132
|
+
example "cellpadding_expected_errors" do
|
133
|
+
expect{ @table.cellpadding = -1 }.to raise_error(ArgumentError)
|
134
|
+
end
|
135
|
+
|
136
|
+
example "cellspacing" do
|
137
|
+
expect(@table).to respond_to(:cellspacing)
|
138
|
+
expect(@table).to respond_to(:cellspacing=)
|
139
|
+
expect{ @table.cellspacing }.not_to raise_error
|
140
|
+
expect{ @table.cellspacing = 1 }.not_to raise_error
|
141
|
+
end
|
142
|
+
|
143
|
+
example "cellspacing_expected_errors" do
|
144
|
+
expect{ @table.cellspacing = -1 }.to raise_error(ArgumentError)
|
145
|
+
end
|
146
|
+
|
147
|
+
example "char" do
|
148
|
+
expect(@table).to respond_to(:char)
|
149
|
+
expect(@table).to respond_to(:char=)
|
150
|
+
expect{ @table.char }.not_to raise_error
|
151
|
+
expect{ @table.char = 'x' }.not_to raise_error
|
152
|
+
end
|
153
|
+
|
154
|
+
example "char_expected_errors" do
|
155
|
+
expect{ @table.char = 'xx' }.to raise_error(ArgumentError)
|
156
|
+
end
|
157
|
+
|
158
|
+
example "charoff" do
|
159
|
+
expect(@table).to respond_to(:charoff)
|
160
|
+
expect(@table).to respond_to(:charoff=)
|
161
|
+
expect{ @table.charoff }.not_to raise_error
|
162
|
+
expect{ @table.charoff = 1 }.not_to raise_error
|
163
|
+
end
|
164
|
+
|
165
|
+
example "charoff_expected_errors" do
|
166
|
+
expect{ @table.charoff = -1 }.to raise_error(ArgumentError)
|
167
|
+
end
|
168
|
+
|
169
|
+
example "class" do
|
170
|
+
expect(@table).to respond_to(:class_)
|
171
|
+
expect(@table).to respond_to(:class_=)
|
172
|
+
expect{ @table.class_ }.not_to raise_error
|
173
|
+
expect{ @table.class_ = 'myclass' }.not_to raise_error
|
174
|
+
end
|
175
|
+
|
176
|
+
example "col" do
|
177
|
+
expect(@table).to respond_to(:col)
|
178
|
+
expect(@table).to respond_to(:col=)
|
179
|
+
expect{ @table.col }.not_to raise_error
|
180
|
+
expect{ @table.col = 1 }.not_to raise_error
|
181
|
+
end
|
182
|
+
|
183
|
+
example "col_expected_errors" do
|
184
|
+
expect{ @table.col = -1 }.to raise_error(ArgumentError)
|
185
|
+
end
|
186
|
+
|
187
|
+
example "colspan" do
|
188
|
+
expect(@table).to respond_to(:colspan)
|
189
|
+
expect(@table).to respond_to(:colspan=)
|
190
|
+
expect{ @table.colspan }.not_to raise_error
|
191
|
+
expect{ @table.colspan = 1 }.not_to raise_error
|
192
|
+
end
|
193
|
+
|
194
|
+
example "colspan_expected_errors" do
|
195
|
+
expect{ @table.colspan = -1 }.to raise_error(ArgumentError)
|
196
|
+
end
|
197
|
+
|
198
|
+
example "configure" do
|
199
|
+
expect(@table).to respond_to(:configure)
|
200
|
+
expect{ @table.configure(0){}.not_to raise_error }
|
201
|
+
expect{ @table.configure(0,0){}.not_to raise_error }
|
202
|
+
end
|
203
|
+
|
204
|
+
example "configure_expected_errors" do
|
205
|
+
expect{ @table.configure(0,0,0){}.to raise_error(ArgumentError) }
|
206
|
+
end
|
207
|
+
|
208
|
+
########################################################################
|
209
|
+
# This test could probably be broken out into separate tests for each
|
210
|
+
# type that we want to add as content.
|
211
|
+
########################################################################
|
212
|
+
example "content" do
|
213
|
+
expect(@table).to respond_to(:content)
|
214
|
+
expect(@table).to respond_to(:content=)
|
215
|
+
expect{ @table.content = 'foo' }.not_to raise_error
|
216
|
+
expect{ @table.content = 123 }.not_to raise_error
|
217
|
+
expect{ @table.content = ['one',2,'three'] }.not_to raise_error
|
218
|
+
expect{ @table.content = [['foo','bar'],[1,2,3]] }.not_to raise_error
|
219
|
+
expect{ @table.content = HTML::Table::Row.new }.not_to raise_error
|
220
|
+
expect{ @table.content = HTML::Table::Row::Data.new }.not_to raise_error
|
221
|
+
expect{ @table.content = HTML::Table::Row::Header.new }.not_to raise_error
|
222
|
+
expect{ @table.content = HTML::Table::Head.create }.not_to raise_error
|
223
|
+
expect{ @table.content = HTML::Table::Foot.create }.not_to raise_error
|
224
|
+
expect{ @table.content = HTML::Table::Body.new }.not_to raise_error
|
225
|
+
end
|
226
|
+
|
227
|
+
example "frame" do
|
228
|
+
expect(@table).to respond_to(:frame)
|
229
|
+
expect(@table).to respond_to(:frame=)
|
230
|
+
expect{ @table.frame }.not_to raise_error
|
231
|
+
expect{ @table.frame = 'below' }.not_to raise_error
|
232
|
+
end
|
233
|
+
|
234
|
+
example "frame_expected_errors" do
|
235
|
+
expect{ @table.frame = 'foo' }.to raise_error(ArgumentError)
|
236
|
+
end
|
237
|
+
|
238
|
+
example "height" do
|
239
|
+
expect(@table).to respond_to(:height)
|
240
|
+
expect(@table).to respond_to(:height=)
|
241
|
+
expect{ @table.height }.not_to raise_error
|
242
|
+
expect{ @table.height = 1 }.not_to raise_error
|
243
|
+
end
|
244
|
+
|
245
|
+
example "height_expected_errors" do
|
246
|
+
expect{ @table.height = -1 }.to raise_error(ArgumentError)
|
247
|
+
end
|
248
|
+
|
249
|
+
example "hspace" do
|
250
|
+
expect(@table).to respond_to(:hspace)
|
251
|
+
expect(@table).to respond_to(:hspace=)
|
252
|
+
expect{ @table.hspace }.not_to raise_error
|
253
|
+
expect{ @table.hspace = 1 }.not_to raise_error
|
254
|
+
end
|
255
|
+
|
256
|
+
example "hspace_expected_errors" do
|
257
|
+
expect{ @table.hspace = -1 }.to raise_error(ArgumentError)
|
258
|
+
end
|
259
|
+
|
260
|
+
example "nowrap" do
|
261
|
+
expect(@table).to respond_to(:nowrap)
|
262
|
+
expect(@table).to respond_to(:nowrap=)
|
263
|
+
expect{ @table.nowrap }.not_to raise_error
|
264
|
+
expect{ @table.nowrap = false }.not_to raise_error
|
265
|
+
end
|
266
|
+
|
267
|
+
example "nowrap_expected_errors" do
|
268
|
+
expect{ @table.nowrap = 'foo' }.to raise_error(TypeError)
|
269
|
+
end
|
270
|
+
|
271
|
+
example "rowspan" do
|
272
|
+
expect(@table).to respond_to(:rowspan)
|
273
|
+
expect(@table).to respond_to(:rowspan=)
|
274
|
+
expect{ @table.rowspan }.not_to raise_error
|
275
|
+
expect{ @table.rowspan = 1 }.not_to raise_error
|
276
|
+
end
|
277
|
+
|
278
|
+
example "rowspan_expected_errors" do
|
279
|
+
expect{ @table.rowspan = -1 }.to raise_error(ArgumentError)
|
280
|
+
end
|
281
|
+
|
282
|
+
example "rules" do
|
283
|
+
expect(@table).to respond_to(:rules)
|
284
|
+
expect(@table).to respond_to(:rules=)
|
285
|
+
expect{ @table.rules }.not_to raise_error
|
286
|
+
expect{ @table.rules = 'all' }.not_to raise_error
|
287
|
+
end
|
288
|
+
|
289
|
+
example "rules_expected_errors" do
|
290
|
+
expect{ @table.rules = 'foo' }.to raise_error(ArgumentError)
|
291
|
+
end
|
292
|
+
|
293
|
+
example "span" do
|
294
|
+
expect(@table).to respond_to(:span)
|
295
|
+
expect(@table).to respond_to(:span=)
|
296
|
+
expect{ @table.span }.not_to raise_error
|
297
|
+
expect{ @table.span = 1 }.not_to raise_error
|
298
|
+
end
|
299
|
+
|
300
|
+
example "span_expected_errors" do
|
301
|
+
expect{ @table.span = -1 }.to raise_error(ArgumentError)
|
302
|
+
end
|
303
|
+
|
304
|
+
example "style" do
|
305
|
+
expect(@table).to respond_to(:style)
|
306
|
+
expect(@table).to respond_to(:style=)
|
307
|
+
expect{ @table.style }.not_to raise_error
|
308
|
+
expect{ @table.style = 'color: blue' }.not_to raise_error
|
309
|
+
end
|
310
|
+
|
311
|
+
example "summary" do
|
312
|
+
expect(@table).to respond_to(:summary)
|
313
|
+
expect(@table).to respond_to(:summary=)
|
314
|
+
expect{ @table.summary }.not_to raise_error
|
315
|
+
expect{ @table.summary = 'foo' }.not_to raise_error
|
316
|
+
expect{ @table.summary = 1 }.not_to raise_error
|
317
|
+
end
|
318
|
+
|
319
|
+
example "valign" do
|
320
|
+
expect(@table).to respond_to(:valign)
|
321
|
+
expect(@table).to respond_to(:valign=)
|
322
|
+
expect{ @table.valign }.not_to raise_error
|
323
|
+
expect{ @table.valign = 'center' }.not_to raise_error
|
324
|
+
end
|
325
|
+
|
326
|
+
example "valign_expected_errors" do
|
327
|
+
expect{ @table.valign = 'foo' }.to raise_error(ArgumentError)
|
328
|
+
end
|
329
|
+
|
330
|
+
example "vspace" do
|
331
|
+
expect(@table).to respond_to(:vspace)
|
332
|
+
expect(@table).to respond_to(:vspace=)
|
333
|
+
expect{ @table.vspace }.not_to raise_error
|
334
|
+
expect{ @table.vspace = 1 }.not_to raise_error
|
335
|
+
end
|
336
|
+
|
337
|
+
example "vspace_expected_errors" do
|
338
|
+
expect{ @table.vspace = -1 }.to raise_error(ArgumentError)
|
339
|
+
end
|
340
|
+
|
341
|
+
example "width" do
|
342
|
+
expect(@table).to respond_to(:width)
|
343
|
+
expect(@table).to respond_to(:width=)
|
344
|
+
expect{ @table.width}.not_to raise_error
|
345
|
+
expect{ @table.width = 10 }.not_to raise_error
|
346
|
+
end
|
347
|
+
|
348
|
+
example "width_with_percent" do
|
349
|
+
expect{ @table.width = '5%' }.not_to raise_error
|
350
|
+
expect( @table.width).to eq('5%')
|
351
|
+
end
|
352
|
+
|
353
|
+
example "width_expected_errors" do
|
354
|
+
expect{ @table.width = -1 }.to raise_error(ArgumentError)
|
355
|
+
end
|
356
|
+
|
357
|
+
after(:all) do
|
358
|
+
NonStandardExtensionWarning.enable
|
359
|
+
end
|
360
|
+
end
|