html-table 1.6.3 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGES.rdoc +4 -0
- data/Gemfile +7 -0
- data/MANIFEST.rdoc +18 -17
- data/Rakefile +117 -146
- data/html-table.gemspec +4 -4
- data/lib/html/mixin/attribute_handler.rb +2 -2
- data/lib/html/table.rb +1 -1
- 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 +43 -42
- metadata.gz.sig +0 -0
- data/test/test_attribute_handler.rb +0 -361
- data/test/test_body.rb +0 -87
- data/test/test_caption.rb +0 -80
- data/test/test_col.rb +0 -40
- data/test/test_colgroup.rb +0 -89
- data/test/test_data.rb +0 -77
- data/test/test_foot.rb +0 -111
- data/test/test_head.rb +0 -104
- data/test/test_header.rb +0 -77
- data/test/test_html_handler.rb +0 -37
- data/test/test_row.rb +0 -141
- data/test/test_table.rb +0 -159
- data/test/test_tablesection.rb +0 -42
- data/test/test_tag_handler.rb +0 -90
data/test/test_head.rb
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
###############################################################################
|
2
|
-
# test_head.rb
|
3
|
-
#
|
4
|
-
# Test suite for the Table::Head class. The Table::Head class is a singleton
|
5
|
-
# class, so we have to take extra measures to ensure that a fresh instance
|
6
|
-
# is created between tests.
|
7
|
-
###############################################################################
|
8
|
-
require 'test-unit'
|
9
|
-
require 'html/table'
|
10
|
-
include HTML
|
11
|
-
|
12
|
-
#####################################################################
|
13
|
-
# Ensure that a fresh instance of Table::Head is used between tests
|
14
|
-
# by calling 'refresh' in the 'teardown' method.
|
15
|
-
#####################################################################
|
16
|
-
class Table::Head
|
17
|
-
private
|
18
|
-
def refresh
|
19
|
-
@@head = nil
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class TC_HTML_Table_Head < Test::Unit::TestCase
|
24
|
-
def setup
|
25
|
-
@table = Table.new
|
26
|
-
@thead = Table::Head.create
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_constructor
|
30
|
-
assert_nothing_raised{ Table::Head.create }
|
31
|
-
assert_nothing_raised{ Table::Head.create("foo") }
|
32
|
-
assert_nothing_raised{ Table::Head.create(1) }
|
33
|
-
assert_nothing_raised{ Table::Head.create(%w/foo bar baz/) }
|
34
|
-
assert_nothing_raised{ Table::Head.create([1,2,3]) }
|
35
|
-
assert_nothing_raised{ Table::Head.create([[1,2,3],["foo","bar"]]) }
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_basic
|
39
|
-
html = "<thead></thead>"
|
40
|
-
assert_equal(html,@thead.html.gsub(/\s{2,}|\n/,''))
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_end_tags
|
44
|
-
assert_respond_to(Table::Head, :end_tags?)
|
45
|
-
assert_respond_to(Table::Head, :end_tags=)
|
46
|
-
assert_nothing_raised{ Table::Head.end_tags? }
|
47
|
-
assert_nothing_raised{ Table::Head.end_tags = true }
|
48
|
-
assert_raises(StrongTyping::ArgumentTypeError){
|
49
|
-
Table::Head.end_tags = "foo"
|
50
|
-
}
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_with_attributes
|
54
|
-
html = "<thead align='left' char='x'></thead>"
|
55
|
-
@thead.align = "left"
|
56
|
-
@thead.char = 'x'
|
57
|
-
assert_equal(html,@thead.html.gsub(/\s{2,}|\n/,''))
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_push_single_row
|
61
|
-
html = "<thead><tr><td>test</td></tr></thead>"
|
62
|
-
@thead.push Table::Row.new{|r| r.content = "test"}
|
63
|
-
assert_equal(html,@thead.html.gsub(/\s{2,}|\n/,''))
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_push_multiple_rows
|
67
|
-
html = "<thead><tr><td>test</td></tr><tr><td>foo</td></tr></thead>"
|
68
|
-
r1 = Table::Row.new("test")
|
69
|
-
r2 = Table::Row.new("foo")
|
70
|
-
@thead.push(r1, r2)
|
71
|
-
assert_equal(html,@thead.html.gsub(/\s{2,}|\n/,''))
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_add_content_directly
|
75
|
-
html = "<thead><tr><td>hello</td><td>world</td></tr></thead>"
|
76
|
-
@thead.content = "hello","world"
|
77
|
-
assert_equal(html,@thead.html.gsub(/\s{2,}|\n+/,''))
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_add_content_in_constructor
|
81
|
-
html = "<thead><tr><td>hello</td><td>world</td></tr></thead>"
|
82
|
-
@thead.send(:refresh)
|
83
|
-
@thead = Table::Head.create(["hello","world"])
|
84
|
-
assert_equal(html,@thead.html.gsub(/\s{2,}|\n+/,''))
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_configure_column
|
88
|
-
html = "<thead><tr><td>hello</td><td abbr='test' width=3 nowrap>world"
|
89
|
-
html += "</td></tr></thead>"
|
90
|
-
@thead.content = "hello","world"
|
91
|
-
@thead.configure(0,1){ |d|
|
92
|
-
d.abbr = 'test'
|
93
|
-
d.width = 3
|
94
|
-
d.nowrap = true
|
95
|
-
}
|
96
|
-
assert_equal(html,@thead.html.gsub(/\s{2,}|\n+/,''))
|
97
|
-
end
|
98
|
-
|
99
|
-
def teardown
|
100
|
-
@table = nil
|
101
|
-
@thead.send(:refresh)
|
102
|
-
@thead = nil
|
103
|
-
end
|
104
|
-
end
|
data/test/test_header.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
################################################
|
2
|
-
# test_header.rb
|
3
|
-
#
|
4
|
-
# Test suite for the Table::Row::Header class
|
5
|
-
################################################
|
6
|
-
require 'test-unit'
|
7
|
-
require 'html/table'
|
8
|
-
include HTML
|
9
|
-
|
10
|
-
class TC_HTML_Table_Row_Header < Test::Unit::TestCase
|
11
|
-
def setup
|
12
|
-
@theader = Table::Row::Header.new
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_basic
|
16
|
-
html = "<th></th>"
|
17
|
-
assert_equal(html, @theader.html.gsub(/\s+/,''))
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_constructor
|
21
|
-
assert_nothing_raised{ Table::Row::Header.new }
|
22
|
-
assert_nothing_raised{ Table::Row::Header.new("foo") }
|
23
|
-
assert_nothing_raised{ Table::Row::Header.new(1) }
|
24
|
-
assert_nothing_raised{ Table::Row::Header.new(%w/foo bar baz/) }
|
25
|
-
assert_nothing_raised{ Table::Row::Header.new([1,2,3]) }
|
26
|
-
assert_nothing_raised{ Table::Row::Header.new([[1,2,3],["foo","bar"]]) }
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_with_attributes
|
30
|
-
html = "<th align='left' colspan=3 nowrap></th>"
|
31
|
-
@theader.align = 'left'
|
32
|
-
@theader.colspan = 3
|
33
|
-
@theader.nowrap = true
|
34
|
-
assert_equal(html, @theader.html.gsub(/\s{2,}|\n+/,''))
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_configure_not_allowed
|
38
|
-
assert_raises(NoMethodError){ @theader.configure }
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_add_content
|
42
|
-
html = "<th>hello world</th>"
|
43
|
-
@theader.content = "hello world"
|
44
|
-
assert_equal(html, @theader.html.gsub(/\s{2,}/,''))
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_add_multiple_content_items
|
48
|
-
html = "<th>hello world</th>"
|
49
|
-
@theader.content = "hello"," world"
|
50
|
-
assert_equal(html, @theader.html.gsub(/\s{2,}/,''))
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_add_content_in_constructor
|
54
|
-
html = "<th>hello world</th>"
|
55
|
-
@theader = Table::Row::Header.new("hello world")
|
56
|
-
assert_equal(html, @theader.html.gsub(/\s{2,}/,''))
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_indent_level
|
60
|
-
assert_respond_to(Table::Row::Header,:indent_level)
|
61
|
-
assert_respond_to(Table::Row::Header,:indent_level=)
|
62
|
-
assert_raises(ArgumentTypeError){ Table::Row::Header.indent_level = "foo" }
|
63
|
-
assert_nothing_raised{ Table::Row::Header.indent_level = 6 }
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_end_tags
|
67
|
-
assert_respond_to(Table::Row::Header,:end_tags?)
|
68
|
-
assert_respond_to(Table::Row::Header,:end_tags=)
|
69
|
-
assert_raises(ArgumentTypeError){ Table::Row::Header.end_tags = "foo" }
|
70
|
-
assert_raises(ArgumentTypeError){ Table::Row::Header.end_tags = 1 }
|
71
|
-
assert_nothing_raised{ Table::Row::Header.end_tags = true }
|
72
|
-
end
|
73
|
-
|
74
|
-
def teardown
|
75
|
-
@theader = nil
|
76
|
-
end
|
77
|
-
end
|
data/test/test_html_handler.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
############################################################################
|
2
|
-
# test_html_handler.rb
|
3
|
-
#
|
4
|
-
# Test suite for the HtmlHandler module. For these tests, we'll use an
|
5
|
-
# instance of the Table class where the module has been mixed in.
|
6
|
-
############################################################################
|
7
|
-
require 'test-unit'
|
8
|
-
require 'html/table'
|
9
|
-
include HTML
|
10
|
-
|
11
|
-
class TC_HtmlHandler < Test::Unit::TestCase
|
12
|
-
def setup
|
13
|
-
@table = Table.new(["foo",1,"bar"])
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_html
|
17
|
-
assert_respond_to(@table, :html)
|
18
|
-
assert_nothing_raised{ @table.html }
|
19
|
-
assert_raises(NoMethodError){ @table.html = "foo" }
|
20
|
-
assert_kind_of(String, @table.html)
|
21
|
-
assert_equal(true, @table.html.length > 0)
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_modify_html
|
25
|
-
assert_raises(ArgumentError){ @table.send(:modify_html) }
|
26
|
-
assert_nothing_raised{ @table.send(:modify_html,"nowrap") }
|
27
|
-
assert_nothing_raised{ @table.send(:modify_html,"align","top") }
|
28
|
-
assert_nothing_raised{
|
29
|
-
@table.send(:modify_html,"align","top")
|
30
|
-
@table.send(:modify_html,"align","top")
|
31
|
-
}
|
32
|
-
end
|
33
|
-
|
34
|
-
def teardown
|
35
|
-
@table = nil
|
36
|
-
end
|
37
|
-
end
|
data/test/test_row.rb
DELETED
@@ -1,141 +0,0 @@
|
|
1
|
-
############################################
|
2
|
-
# test_row.rb
|
3
|
-
#
|
4
|
-
# Test suite for the Table::Row class
|
5
|
-
############################################
|
6
|
-
require 'test-unit'
|
7
|
-
require 'html/table'
|
8
|
-
include HTML
|
9
|
-
|
10
|
-
class TC_HTML_Table_Row < Test::Unit::TestCase
|
11
|
-
def setup
|
12
|
-
@trow = Table::Row.new
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_constructor
|
16
|
-
assert_nothing_raised{ Table::Row.new }
|
17
|
-
assert_nothing_raised{ Table::Row.new("foo") }
|
18
|
-
assert_nothing_raised{ Table::Row.new(1) }
|
19
|
-
assert_nothing_raised{ Table::Row.new([1,2,3]) }
|
20
|
-
assert_nothing_raised{ Table::Row.new([[1,2,3],["foo","bar"]]) }
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_basic
|
24
|
-
html = "<tr></tr>"
|
25
|
-
assert_equal(html,@trow.html.gsub(/\s+/,''))
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_header
|
29
|
-
assert_respond_to(@trow, :header?)
|
30
|
-
assert_respond_to(@trow, :header=)
|
31
|
-
assert_nothing_raised{ @trow.header? }
|
32
|
-
assert_nothing_raised{ @trow.header = true }
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_with_attributes
|
36
|
-
html = "<tr align='center'></tr>"
|
37
|
-
@trow.align = "center"
|
38
|
-
assert_equal(html, @trow.html.gsub(/\s{2,}|\n+/,''))
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_index_assignment_constraints
|
42
|
-
assert_raises(ArgumentTypeError){ @trow[0] = "foo" }
|
43
|
-
assert_raises(ArgumentTypeError){ @trow[0] = 1 }
|
44
|
-
assert_raises(ArgumentTypeError){ @trow[0] = Table::Caption.new }
|
45
|
-
assert_nothing_raised{ @trow[0] = Table::Row::Data.new }
|
46
|
-
assert_nothing_raised{ @trow[0] = Table::Row::Header.new }
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_push_constraints
|
50
|
-
assert_raises(ArgumentTypeError){ @trow.push(Table::Caption.new) }
|
51
|
-
assert_raises(ArgumentTypeError){ @trow.push(nil) }
|
52
|
-
assert_nothing_raised{ @trow.push("test") }
|
53
|
-
assert_nothing_raised{ @trow.push(7) }
|
54
|
-
assert_nothing_raised{ @trow.push(Table::Row::Data.new) }
|
55
|
-
assert_nothing_raised{ @trow.push(Table::Row::Header.new) }
|
56
|
-
end
|
57
|
-
|
58
|
-
# Test the '<<' method
|
59
|
-
def test_doubl_arrow_constraints
|
60
|
-
assert_raises(ArgumentTypeError){ @trow << Table::Caption.new }
|
61
|
-
assert_nothing_raised{ @trow << "test" }
|
62
|
-
assert_nothing_raised{ @trow << "test" << "foo" }
|
63
|
-
assert_nothing_raised{ @trow << Table::Row::Data.new }
|
64
|
-
assert_nothing_raised{ @trow << Table::Row::Header.new }
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_header_in_constructor
|
68
|
-
assert_nothing_raised{ @trow = Table::Row.new('test', true) }
|
69
|
-
html = "<tr><th>test</th></tr>"
|
70
|
-
assert_equal(html, @trow.html.gsub(/\s+/,''))
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_push_single_data_element
|
74
|
-
html = "<tr><td>hello</td></tr>"
|
75
|
-
@trow.push Table::Row::Data.new{ |d| d.content = "hello" }
|
76
|
-
assert_equal(html, @trow.html.gsub(/\s{2,}|\n+/,''))
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_push_multiple_data_element
|
80
|
-
html = "<tr><td>hello</td><td>world</td></tr>"
|
81
|
-
d1 = Table::Row::Data.new{ |d| d.content = "hello" }
|
82
|
-
d2 = Table::Row::Data.new{ |d| d.content = "world" }
|
83
|
-
@trow.push d1, d2
|
84
|
-
assert_equal(html, @trow.html.gsub(/\s{2,}|\n+/,''))
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_add_content_directly
|
88
|
-
html = "<tr><td>hello</td><td>world</td></tr>"
|
89
|
-
@trow.content = "hello","world"
|
90
|
-
assert_equal(html, @trow.html.gsub(/\s{2,}|\n+/,''))
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_add_content_in_constructor
|
94
|
-
html = "<tr><td>hello</td><td>world</td></tr>"
|
95
|
-
@trow = Table::Row.new(%w/hello world/)
|
96
|
-
assert_equal(html, @trow.html.gsub(/\s{2,}|\n+/,''))
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_configure_column
|
100
|
-
html = "<tr><td>hello</td><td abbr='test' width=3 nowrap>world</td></tr>"
|
101
|
-
@trow.content = "hello","world"
|
102
|
-
@trow.configure(1){ |d|
|
103
|
-
d.abbr = 'test'
|
104
|
-
d.width = 3
|
105
|
-
d.nowrap = true
|
106
|
-
}
|
107
|
-
assert_equal(html, @trow.html.gsub(/\s{2,}|\n+/,''))
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_unshift_constraints
|
111
|
-
assert_raises(ArgumentTypeError){ @trow.unshift(Table::Caption.new) }
|
112
|
-
assert_raises(ArgumentTypeError){ @trow.unshift(nil) }
|
113
|
-
assert_nothing_raised{ @trow.unshift("test") }
|
114
|
-
assert_nothing_raised{ @trow.unshift(7) }
|
115
|
-
assert_nothing_raised{ @trow.unshift(Table::Row::Data.new) }
|
116
|
-
assert_nothing_raised{ @trow.unshift(Table::Row::Header.new) }
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_configure_error
|
120
|
-
assert_raises(ArgumentError){ @trow.configure(0,0){ } }
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_indent_level
|
124
|
-
assert_respond_to(Table::Row,:indent_level)
|
125
|
-
assert_respond_to(Table::Row,:indent_level=)
|
126
|
-
assert_raises(ArgumentTypeError){ Table::Row.indent_level = "foo" }
|
127
|
-
assert_nothing_raised{ Table::Row.indent_level = 3 }
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_end_tags
|
131
|
-
assert_respond_to(Table::Row,:end_tags?)
|
132
|
-
assert_respond_to(Table::Row,:end_tags=)
|
133
|
-
assert_raises(ArgumentTypeError){ Table::Row.end_tags = "foo" }
|
134
|
-
assert_raises(ArgumentTypeError){ Table::Row.end_tags = 1 }
|
135
|
-
assert_nothing_raised{ Table::Row.end_tags = true }
|
136
|
-
end
|
137
|
-
|
138
|
-
def teardown
|
139
|
-
@trow = nil
|
140
|
-
end
|
141
|
-
end
|
data/test/test_table.rb
DELETED
@@ -1,159 +0,0 @@
|
|
1
|
-
#######################################################################
|
2
|
-
# test_table.rb
|
3
|
-
#
|
4
|
-
# Test suite for the HTML::Table class. This test case should be run
|
5
|
-
# via the 'rake test' task.
|
6
|
-
#######################################################################
|
7
|
-
require 'test-unit'
|
8
|
-
require 'html/table'
|
9
|
-
require 'strongtyping'
|
10
|
-
include StrongTyping
|
11
|
-
include HTML
|
12
|
-
|
13
|
-
class TC_HTML_Table < Test::Unit::TestCase
|
14
|
-
def setup
|
15
|
-
@table = Table.new
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_version
|
19
|
-
assert_equal('1.6.3', Table::VERSION)
|
20
|
-
assert_true(Table::VERSION.frozen?)
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_constructor
|
24
|
-
assert_nothing_raised{ Table.new }
|
25
|
-
assert_nothing_raised{ Table.new('foo') }
|
26
|
-
assert_nothing_raised{ Table.new(1) }
|
27
|
-
assert_nothing_raised{ Table.new(%w/foo bar baz/) }
|
28
|
-
assert_nothing_raised{ Table.new([1,2,3]) }
|
29
|
-
assert_nothing_raised{ Table.new([[1,2,3],['foo','bar']]) }
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_constructor_with_attributes
|
33
|
-
assert_nothing_raised{ Table.new(%w[foo bar baz], :border => 1) }
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_html_case
|
37
|
-
assert_respond_to(Table, :html_case)
|
38
|
-
assert_respond_to(Table, :html_case=)
|
39
|
-
assert_nothing_raised{ Table.html_case = 'upper' }
|
40
|
-
assert_nothing_raised{ Table.html_case = 'lower' }
|
41
|
-
assert_raises(ArgumentError){ Table.html_case = 'foo' }
|
42
|
-
assert_raises(ArgumentTypeError){ Table.html_case = 7 }
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_indent_level
|
46
|
-
assert_respond_to(Table, :indent_level)
|
47
|
-
assert_respond_to(Table, :indent_level=)
|
48
|
-
assert_nothing_raised{ Table.indent_level = 0 }
|
49
|
-
assert_raises(ArgumentTypeError){ Table.indent_level = 'foo' }
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_index
|
53
|
-
assert_raises(ArgumentTypeError){ @table[0] = 'foo' }
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_caption_index_constraints
|
57
|
-
assert_nothing_raised{ @table[0] = Table::Caption.new }
|
58
|
-
assert_raises(ArgumentError){ @table[1] = Table::Caption.new }
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_head_index_constraints
|
62
|
-
assert_nothing_raised{ @table[0] = Table::Head.create }
|
63
|
-
assert_raises(ArgumentError){ @table[1] = Table::Head.create }
|
64
|
-
assert_raises(ArgumentError){ @table[2] = Table::Head.create }
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_foot_index_constraints
|
68
|
-
assert_nothing_raised{
|
69
|
-
@table[0] = Table::Caption.new
|
70
|
-
@table[-1] = Table::Foot.create
|
71
|
-
}
|
72
|
-
assert_raises(ArgumentError){ @table[0] = Table::Foot.create }
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_unshift_constraints
|
76
|
-
assert_nothing_raised{ @table.unshift Table::Row.new }
|
77
|
-
assert_raises(ArgumentTypeError){ @table.unshift Table::Row::Data.new }
|
78
|
-
assert_raises(ArgumentTypeError){ @table.unshift 'foo' }
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_push_constraints
|
82
|
-
assert_nothing_raised{ @table.push Table::Row.new }
|
83
|
-
assert_raises(ArgumentTypeError){ @table.push('foo') }
|
84
|
-
assert_raises(ArgumentTypeError){ @table.push(7) }
|
85
|
-
assert_raises(ArgumentTypeError){ @table.push(nil) }
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_double_arrow_constraints
|
89
|
-
assert_nothing_raised{ @table << Table::Row.new }
|
90
|
-
assert_nothing_raised{ @table << Table::Row.new << Table::Row.new }
|
91
|
-
assert_raises(ArgumentTypeError){ @table << 'foo' }
|
92
|
-
assert_raises(ArgumentTypeError){ @table << 7 }
|
93
|
-
assert_raises(ArgumentTypeError){ @table << nil }
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_basic
|
97
|
-
html = "<table>\n</table>"
|
98
|
-
assert_equal(html, @table.html)
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_with_attributes
|
102
|
-
html = "<table border=1 align='left' nowrap>\n</table>"
|
103
|
-
@table.border = 1
|
104
|
-
@table.align = 'left'
|
105
|
-
@table.nowrap = true
|
106
|
-
assert_equal(html, @table.html)
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_add_row_push
|
110
|
-
html = '<table><tr></tr></table>'
|
111
|
-
@table.push(Table::Row.new)
|
112
|
-
assert_equal(html, @table.html.gsub(/\s+/,''))
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_add_row_by_index
|
116
|
-
html = '<table><tr></tr></table>'
|
117
|
-
@table[0] = Table::Row.new
|
118
|
-
assert_equal(html, @table.html.gsub(/\s+/,''))
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_add_multiple_rows
|
122
|
-
html = '<table><tr></tr><tr></tr></table>'
|
123
|
-
@table.push Table::Row.new, Table::Row.new
|
124
|
-
assert_equal(html, @table.html.gsub(/\s+/,''))
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_add_single_data_element
|
128
|
-
html = '<table><tr><td>hello</td></tr></table>'
|
129
|
-
@table.content = 'hello'
|
130
|
-
assert_equal(html, @table.html.gsub(/\s+/,''))
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_add_multiple_data_elements
|
134
|
-
html = '<table><tr><td>hello</td></tr><tr><td>world</td></tr></table>'
|
135
|
-
@table.content = 'hello','world'
|
136
|
-
assert_equal(html, @table.html.gsub(/\s+/,''))
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_configure_row
|
140
|
-
html = "<table><tr align='center'><td bgcolor='red'>hello</td></tr>"
|
141
|
-
html << '</table>'
|
142
|
-
@table.push Table::Row::Data.new{ |d| d.content = 'hello' }
|
143
|
-
@table.configure(0){ |t| t.align = 'center' }
|
144
|
-
@table.configure(0,0){ |d| d.bgcolor = 'red' }
|
145
|
-
assert_equal(html, @table.html.gsub(/\s{2,}|\n+/,''))
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_global_end_tags
|
149
|
-
assert_respond_to(Table,:global_end_tags?)
|
150
|
-
assert_respond_to(Table,:global_end_tags=)
|
151
|
-
assert_nothing_raised{ Table.global_end_tags = false }
|
152
|
-
assert_nothing_raised{ Table.global_end_tags = true }
|
153
|
-
assert_raises(ArgumentTypeError){ Table.global_end_tags = 'foo' }
|
154
|
-
end
|
155
|
-
|
156
|
-
def teardown
|
157
|
-
@table = nil
|
158
|
-
end
|
159
|
-
end
|