table_helper 0.0.5 → 0.1.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.
- data/{CHANGELOG → CHANGELOG.rdoc} +11 -10
- data/{MIT-LICENSE → LICENSE} +0 -0
- data/{README → README.rdoc} +9 -9
- data/Rakefile +44 -36
- data/lib/table_helper.rb +173 -175
- data/lib/table_helper/body.rb +102 -105
- data/lib/table_helper/body_row.rb +58 -74
- data/lib/table_helper/cell.rb +44 -46
- data/lib/table_helper/collection_table.rb +53 -49
- data/lib/table_helper/footer.rb +36 -38
- data/lib/table_helper/header.rb +138 -140
- data/lib/table_helper/html_element.rb +39 -41
- data/lib/table_helper/row.rb +85 -87
- data/test/{table_helper_test.rb → helpers/table_helper_test.rb} +5 -5
- data/test/test_helper.rb +4 -7
- data/test/{body_row_test.rb → unit/body_row_test.rb} +13 -13
- data/test/{body_test.rb → unit/body_test.rb} +35 -35
- data/test/{cell_test.rb → unit/cell_test.rb} +7 -7
- data/test/{collection_table_test.rb → unit/collection_table_test.rb} +31 -31
- data/test/{footer_test.rb → unit/footer_test.rb} +12 -12
- data/test/{header_builder_test.rb → unit/header_builder_test.rb} +8 -8
- data/test/{header_test.rb → unit/header_test.rb} +36 -36
- data/test/{html_element_test.rb → unit/html_element_test.rb} +8 -8
- data/test/{row_builder_test.rb → unit/row_builder_test.rb} +9 -9
- data/test/{row_test.rb → unit/row_test.rb} +11 -11
- metadata +37 -35
@@ -1,8 +1,8 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
3
|
class CellByDefaultTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@cell =
|
5
|
+
@cell = TableHelper::Cell.new(:name)
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_should_have_a_class_name
|
@@ -20,29 +20,29 @@ end
|
|
20
20
|
|
21
21
|
class CellTest < Test::Unit::TestCase
|
22
22
|
def test_should_use_custom_content_if_specified
|
23
|
-
cell =
|
23
|
+
cell = TableHelper::Cell.new(:name, 'John Doe')
|
24
24
|
assert_equal '<td class="name">John Doe</td>', cell.html
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_should_include_custom_html_options
|
28
|
-
cell =
|
28
|
+
cell = TableHelper::Cell.new(:name, 'John Doe', {:float => 'left'})
|
29
29
|
assert_equal '<td class="name" float="left">John Doe</td>', cell.html
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_should_append_automated_class_name_if_class_already_specified
|
33
|
-
cell =
|
33
|
+
cell = TableHelper::Cell.new(:name, 'John Doe', {:class => 'selected'})
|
34
34
|
assert_equal 'name selected', cell[:class]
|
35
35
|
assert_equal '<td class="name selected">John Doe</td>', cell.html
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_should_raise_exception_if_content_type_is_invalid
|
39
|
-
assert_raise(ArgumentError) {
|
39
|
+
assert_raise(ArgumentError) {TableHelper::Cell.new(:name).content_type = :invalid}
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
class CellWithHeaderContentType < Test::Unit::TestCase
|
44
44
|
def setup
|
45
|
-
@cell =
|
45
|
+
@cell = TableHelper::Cell.new(:name)
|
46
46
|
@cell.content_type = :header
|
47
47
|
end
|
48
48
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
3
|
class CollectionTableByDefaultTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@table =
|
5
|
+
@table = TableHelper::CollectionTable.new([])
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_cellspacing_should_be_zero
|
@@ -15,11 +15,11 @@ class CollectionTableByDefaultTest < Test::Unit::TestCase
|
|
15
15
|
|
16
16
|
def test_should_include_header_and_footer
|
17
17
|
html = @table.build do |header, body|
|
18
|
-
assert_instance_of
|
19
|
-
assert_instance_of
|
18
|
+
assert_instance_of TableHelper::Header, header
|
19
|
+
assert_instance_of TableHelper::Body, body
|
20
20
|
end
|
21
21
|
|
22
|
-
expected = <<-
|
22
|
+
expected = <<-end_str
|
23
23
|
<thead style="display: none;">
|
24
24
|
<tr></tr>
|
25
25
|
</thead>
|
@@ -28,7 +28,7 @@ class CollectionTableByDefaultTest < Test::Unit::TestCase
|
|
28
28
|
<td>No matches found.</td>
|
29
29
|
</tr>
|
30
30
|
</tbody>
|
31
|
-
|
31
|
+
end_str
|
32
32
|
assert_html_equal expected, html
|
33
33
|
end
|
34
34
|
end
|
@@ -73,16 +73,16 @@ class CollectionTableTest < Test::Unit::TestCase
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def test_should_raise_exception_if_invalid_option_specified
|
76
|
-
assert_raise(ArgumentError) {
|
76
|
+
assert_raise(ArgumentError) {TableHelper::CollectionTable.new([], :invalid => true)}
|
77
77
|
end
|
78
78
|
|
79
79
|
def test_should_only_include_body_if_no_header
|
80
|
-
table =
|
80
|
+
table = TableHelper::CollectionTable.new(@collection, :header => false)
|
81
81
|
html = table.build do |body|
|
82
|
-
assert_instance_of
|
82
|
+
assert_instance_of TableHelper::Body, body
|
83
83
|
end
|
84
84
|
|
85
|
-
expected = <<-
|
85
|
+
expected = <<-end_str
|
86
86
|
<tbody>
|
87
87
|
<tr class="row">
|
88
88
|
<td class="title">first</td>
|
@@ -94,18 +94,18 @@ class CollectionTableTest < Test::Unit::TestCase
|
|
94
94
|
<td class="title">last</td>
|
95
95
|
</tr>
|
96
96
|
</tbody>
|
97
|
-
|
97
|
+
end_str
|
98
98
|
assert_html_equal expected, html
|
99
99
|
end
|
100
100
|
|
101
101
|
def test_should_include_body_and_footer_if_no_header_and_footer
|
102
|
-
table =
|
102
|
+
table = TableHelper::CollectionTable.new(@collection, :header => false, :footer => true)
|
103
103
|
html = table.build do |body, footer|
|
104
|
-
assert_instance_of
|
105
|
-
assert_instance_of
|
104
|
+
assert_instance_of TableHelper::Body, body
|
105
|
+
assert_instance_of TableHelper::Footer, footer
|
106
106
|
end
|
107
107
|
|
108
|
-
expected = <<-
|
108
|
+
expected = <<-end_str
|
109
109
|
<tbody>
|
110
110
|
<tr class="row">
|
111
111
|
<td class="title">first</td>
|
@@ -121,19 +121,19 @@ class CollectionTableTest < Test::Unit::TestCase
|
|
121
121
|
<tr>
|
122
122
|
</tr>
|
123
123
|
</tfoot>
|
124
|
-
|
124
|
+
end_str
|
125
125
|
assert_html_equal expected, html
|
126
126
|
end
|
127
127
|
|
128
128
|
def test_should_include_header_body_and_footer_if_footer
|
129
|
-
table =
|
129
|
+
table = TableHelper::CollectionTable.new(@collection, :footer => true)
|
130
130
|
html = table.build do |header, body, footer|
|
131
|
-
assert_instance_of
|
132
|
-
assert_instance_of
|
133
|
-
assert_instance_of
|
131
|
+
assert_instance_of TableHelper::Header, header
|
132
|
+
assert_instance_of TableHelper::Body, body
|
133
|
+
assert_instance_of TableHelper::Footer, footer
|
134
134
|
end
|
135
135
|
|
136
|
-
expected = <<-
|
136
|
+
expected = <<-end_str
|
137
137
|
<thead>
|
138
138
|
<tr>
|
139
139
|
<th class="title" scope="col">Title</th>
|
@@ -154,15 +154,15 @@ class CollectionTableTest < Test::Unit::TestCase
|
|
154
154
|
<tr>
|
155
155
|
</tr>
|
156
156
|
</tfoot>
|
157
|
-
|
157
|
+
end_str
|
158
158
|
assert_html_equal expected, html
|
159
159
|
end
|
160
160
|
|
161
161
|
def test_should_use_custom_class_to_generate_columns
|
162
|
-
table =
|
162
|
+
table = TableHelper::CollectionTable.new(@collection, :class => Note)
|
163
163
|
html = table.build
|
164
164
|
|
165
|
-
expected = <<-
|
165
|
+
expected = <<-end_str
|
166
166
|
<thead>
|
167
167
|
<tr>
|
168
168
|
<th class="title" scope="col">Title</th>
|
@@ -183,16 +183,16 @@ class CollectionTableTest < Test::Unit::TestCase
|
|
183
183
|
<td class="author_name empty"></td>
|
184
184
|
</tr>
|
185
185
|
</tbody>
|
186
|
-
|
186
|
+
end_str
|
187
187
|
assert_html_equal expected, html
|
188
188
|
end
|
189
189
|
|
190
190
|
def test_should_use_class_from_first_element_to_generate_columns
|
191
191
|
@collection.insert(0, Note.new('zeroth'))
|
192
|
-
table =
|
192
|
+
table = TableHelper::CollectionTable.new(@collection)
|
193
193
|
html = table.build
|
194
194
|
|
195
|
-
expected = <<-
|
195
|
+
expected = <<-end_str
|
196
196
|
<thead>
|
197
197
|
<tr>
|
198
198
|
<th class="title" scope="col">Title</th>
|
@@ -217,17 +217,17 @@ class CollectionTableTest < Test::Unit::TestCase
|
|
217
217
|
<td class="author_name empty"></td>
|
218
218
|
</tr>
|
219
219
|
</tbody>
|
220
|
-
|
220
|
+
end_str
|
221
221
|
assert_html_equal expected, html
|
222
222
|
end
|
223
223
|
|
224
224
|
def test_should_use_class_from_proxy_reflection_to_generate_columns
|
225
225
|
collection = NoteCollection.new
|
226
226
|
collection.concat(@collection)
|
227
|
-
table =
|
227
|
+
table = TableHelper::CollectionTable.new(collection)
|
228
228
|
html = table.build
|
229
229
|
|
230
|
-
expected = <<-
|
230
|
+
expected = <<-end_str
|
231
231
|
<thead>
|
232
232
|
<tr>
|
233
233
|
<th class="title" scope="col">Title</th>
|
@@ -248,7 +248,7 @@ class CollectionTableTest < Test::Unit::TestCase
|
|
248
248
|
<td class="author_name empty"></td>
|
249
249
|
</tr>
|
250
250
|
</tbody>
|
251
|
-
|
251
|
+
end_str
|
252
252
|
assert_html_equal expected, html
|
253
253
|
end
|
254
254
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
3
|
class FooterByDefaultTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@footer =
|
5
|
+
@footer = TableHelper::Footer.new([])
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_should_hdie_when_empty
|
@@ -12,61 +12,61 @@ end
|
|
12
12
|
|
13
13
|
class FooterTest < Test::Unit::TestCase
|
14
14
|
def setup
|
15
|
-
@footer =
|
15
|
+
@footer = TableHelper::Footer.new([1])
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_should_include_custom_attributes
|
19
19
|
@footer[:class] = 'pretty'
|
20
20
|
|
21
|
-
expected = <<-
|
21
|
+
expected = <<-end_str
|
22
22
|
<tfoot class="pretty">
|
23
23
|
<tr>
|
24
24
|
</tr>
|
25
25
|
</tfoot>
|
26
|
-
|
26
|
+
end_str
|
27
27
|
assert_html_equal expected, @footer.html
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_should_include_created_cells_when_built
|
31
31
|
@footer.cell :total, 20
|
32
32
|
|
33
|
-
expected = <<-
|
33
|
+
expected = <<-end_str
|
34
34
|
<tfoot>
|
35
35
|
<tr>
|
36
36
|
<td class="total">20</td>
|
37
37
|
</tr>
|
38
38
|
</tfoot>
|
39
|
-
|
39
|
+
end_str
|
40
40
|
assert_html_equal expected, @footer.html
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
class FooterWithEmptyCollectionTest < Test::Unit::TestCase
|
45
45
|
def setup
|
46
|
-
@footer =
|
46
|
+
@footer = TableHelper::Footer.new([])
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_should_not_display_if_hide_when_empty
|
50
50
|
@footer.hide_when_empty = true
|
51
51
|
|
52
|
-
expected = <<-
|
52
|
+
expected = <<-end_str
|
53
53
|
<tfoot style="display: none;">
|
54
54
|
<tr>
|
55
55
|
</tr>
|
56
56
|
</tfoot>
|
57
|
-
|
57
|
+
end_str
|
58
58
|
assert_html_equal expected, @footer.html
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_should_display_if_not_hide_when_empty
|
62
62
|
@footer.hide_when_empty = false
|
63
63
|
|
64
|
-
expected = <<-
|
64
|
+
expected = <<-end_str
|
65
65
|
<tfoot>
|
66
66
|
<tr>
|
67
67
|
</tr>
|
68
68
|
</tfoot>
|
69
|
-
|
69
|
+
end_str
|
70
70
|
assert_html_equal expected, @footer.html
|
71
71
|
end
|
72
72
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
3
|
class HeaderBuilderByDefaultTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@header =
|
6
|
-
@builder =
|
5
|
+
@header = TableHelper::Header.new([])
|
6
|
+
@builder = TableHelper::HeaderBuilder.new(@header)
|
7
7
|
end
|
8
8
|
|
9
9
|
def test_should_forward_missing_calls_to_row
|
@@ -13,10 +13,10 @@ end
|
|
13
13
|
|
14
14
|
class HeaderBuilderWithColumnsTest < Test::Unit::TestCase
|
15
15
|
def setup
|
16
|
-
@header =
|
16
|
+
@header = TableHelper::Header.new([])
|
17
17
|
@header.row.cell 'first-name'
|
18
18
|
|
19
|
-
@builder =
|
19
|
+
@builder = TableHelper::HeaderBuilder.new(@header)
|
20
20
|
@builder.define_column('first-name')
|
21
21
|
end
|
22
22
|
|
@@ -25,7 +25,7 @@ class HeaderBuilderWithColumnsTest < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_should_read_column_without_arguments
|
28
|
-
assert_instance_of
|
28
|
+
assert_instance_of TableHelper::Cell, @builder.first_name
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_should_write_cell_with_arguments
|
@@ -36,8 +36,8 @@ end
|
|
36
36
|
|
37
37
|
class RowBuilderAfterUndefiningAColumnTest < Test::Unit::TestCase
|
38
38
|
def setup
|
39
|
-
@header =
|
40
|
-
@builder =
|
39
|
+
@header = TableHelper::Header.new([])
|
40
|
+
@builder = TableHelper::HeaderBuilder.new(@header)
|
41
41
|
@builder.define_column('first-name')
|
42
42
|
@builder.undef_column('first-name')
|
43
43
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
3
|
class HeaderByDefaultTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@header =
|
5
|
+
@header = TableHelper::Header.new([])
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_should_hide_when_empty
|
@@ -34,71 +34,71 @@ class HeaderTest < Test::Unit::TestCase
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_should_use_class_columns_if_class_has_column_names
|
37
|
-
header =
|
37
|
+
header = TableHelper::Header.new([], Post)
|
38
38
|
assert_equal ['title', 'author_name'], header.column_names
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_should_have_no_column_names_if_class_has_no_column_names
|
42
|
-
header =
|
42
|
+
header = TableHelper::Header.new([], Array)
|
43
43
|
assert_equal [], header.column_names
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_should_use_class_columns_if_collection_has_objects
|
47
|
-
header =
|
47
|
+
header = TableHelper::Header.new([Post.new])
|
48
48
|
assert_equal ['title', 'author_name'], header.column_names
|
49
49
|
end
|
50
50
|
|
51
51
|
def test_should_use_class_columns_if_collection_is_proxy
|
52
|
-
header =
|
52
|
+
header = TableHelper::Header.new(PostCollection.new)
|
53
53
|
assert_equal ['title', 'author_name'], header.column_names
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_should_create_column_readers_if_column_names_found
|
57
|
-
header =
|
57
|
+
header = TableHelper::Header.new([], Post)
|
58
58
|
|
59
59
|
assert_nothing_raised {header.builder.title}
|
60
|
-
assert_instance_of
|
60
|
+
assert_instance_of TableHelper::Cell, header.builder.title
|
61
61
|
|
62
62
|
assert_nothing_raised {header.builder.title}
|
63
|
-
assert_instance_of
|
63
|
+
assert_instance_of TableHelper::Cell, header.builder.author_name
|
64
64
|
end
|
65
65
|
|
66
66
|
def test_should_create_column_reader_when_column_is_created
|
67
|
-
header =
|
67
|
+
header = TableHelper::Header.new([])
|
68
68
|
header.column :title
|
69
69
|
|
70
70
|
assert_equal ['title'], header.column_names
|
71
|
-
assert_instance_of
|
71
|
+
assert_instance_of TableHelper::Cell, header.builder.title
|
72
72
|
end
|
73
73
|
|
74
74
|
def test_should_set_column_scope
|
75
|
-
header =
|
75
|
+
header = TableHelper::Header.new([])
|
76
76
|
header.column :title
|
77
77
|
assert_equal 'col', header.columns['title'][:scope]
|
78
78
|
end
|
79
79
|
|
80
80
|
def test_should_allow_html_options_to_be_specified_for_new_columns
|
81
|
-
header =
|
81
|
+
header = TableHelper::Header.new([])
|
82
82
|
header.column :title, 'Title', :class => 'pretty'
|
83
83
|
assert_equal 'title pretty', header.columns['title'][:class]
|
84
84
|
end
|
85
85
|
|
86
86
|
def test_should_use_column_name_for_default_content
|
87
|
-
header =
|
87
|
+
header = TableHelper::Header.new([])
|
88
88
|
header.column :title
|
89
89
|
assert_equal '<th class="title" scope="col">Title</th>', header.columns['title'].html
|
90
90
|
end
|
91
91
|
|
92
92
|
def test_should_sanitize_column_names
|
93
|
-
header =
|
93
|
+
header = TableHelper::Header.new([])
|
94
94
|
header.column 'the-title'
|
95
95
|
|
96
96
|
assert_nothing_raised {header.builder.the_title}
|
97
|
-
assert_instance_of
|
97
|
+
assert_instance_of TableHelper::Cell, header.builder.the_title
|
98
98
|
end
|
99
99
|
|
100
100
|
def test_should_clear_existing_columns_when_first_column_is_created
|
101
|
-
header =
|
101
|
+
header = TableHelper::Header.new([], Post)
|
102
102
|
assert_equal ['title', 'author_name'], header.column_names
|
103
103
|
|
104
104
|
header.column :created_on
|
@@ -109,49 +109,49 @@ class HeaderTest < Test::Unit::TestCase
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def test_should_include_html_options
|
112
|
-
header =
|
112
|
+
header = TableHelper::Header.new([Post.new])
|
113
113
|
header[:class] = 'pretty'
|
114
114
|
|
115
|
-
expected = <<-
|
115
|
+
expected = <<-end_str
|
116
116
|
<thead class="pretty">
|
117
117
|
<tr>
|
118
118
|
<th class="title" scope="col">Title</th>
|
119
119
|
<th class="author_name" scope="col">Author Name</th>
|
120
120
|
</tr>
|
121
121
|
</thead>
|
122
|
-
|
122
|
+
end_str
|
123
123
|
assert_html_equal expected, header.html
|
124
124
|
end
|
125
125
|
|
126
126
|
def test_should_include_html_options_for_header_row
|
127
|
-
header =
|
127
|
+
header = TableHelper::Header.new([Post.new])
|
128
128
|
header.row[:class] = 'pretty'
|
129
129
|
|
130
|
-
expected = <<-
|
130
|
+
expected = <<-end_str
|
131
131
|
<thead>
|
132
132
|
<tr class="pretty">
|
133
133
|
<th class="title" scope="col">Title</th>
|
134
134
|
<th class="author_name" scope="col">Author Name</th>
|
135
135
|
</tr>
|
136
136
|
</thead>
|
137
|
-
|
137
|
+
end_str
|
138
138
|
assert_html_equal expected, header.html
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
142
142
|
class HeaderWithConflictingColumnNamesTest < Test::Unit::TestCase
|
143
143
|
def setup
|
144
|
-
@header =
|
144
|
+
@header = TableHelper::Header.new([])
|
145
145
|
@header.column 'id'
|
146
146
|
end
|
147
147
|
|
148
148
|
def test_should_be_able_to_read_cell
|
149
|
-
assert_instance_of
|
149
|
+
assert_instance_of TableHelper::Cell, @header.builder.id
|
150
150
|
end
|
151
151
|
|
152
152
|
def test_should_be_able_to_write_to_cell
|
153
153
|
@header.builder.id '1'
|
154
|
-
assert_instance_of
|
154
|
+
assert_instance_of TableHelper::Cell, @header.builder.id
|
155
155
|
end
|
156
156
|
|
157
157
|
def test_should_be_able_to_clear
|
@@ -161,30 +161,30 @@ end
|
|
161
161
|
|
162
162
|
class HeaderWithEmptyCollectionTest < Test::Unit::TestCase
|
163
163
|
def setup
|
164
|
-
@header =
|
164
|
+
@header = TableHelper::Header.new([])
|
165
165
|
end
|
166
166
|
|
167
167
|
def test_should_not_display_if_hide_when_empty
|
168
168
|
@header.hide_when_empty = true
|
169
169
|
|
170
|
-
expected = <<-
|
170
|
+
expected = <<-end_str
|
171
171
|
<thead style="display: none;">
|
172
172
|
<tr>
|
173
173
|
</tr>
|
174
174
|
</thead>
|
175
|
-
|
175
|
+
end_str
|
176
176
|
assert_html_equal expected, @header.html
|
177
177
|
end
|
178
178
|
|
179
179
|
def test_should_display_if_not_hide_when_empty
|
180
180
|
@header.hide_when_empty = false
|
181
181
|
|
182
|
-
expected = <<-
|
182
|
+
expected = <<-end_str
|
183
183
|
<thead>
|
184
184
|
<tr>
|
185
185
|
</tr>
|
186
186
|
</thead>
|
187
|
-
|
187
|
+
end_str
|
188
188
|
assert_html_equal expected, @header.html
|
189
189
|
end
|
190
190
|
end
|
@@ -197,34 +197,34 @@ class HeaderWithCollectionTest < Test::Unit::TestCase
|
|
197
197
|
end
|
198
198
|
|
199
199
|
def setup
|
200
|
-
@header =
|
200
|
+
@header = TableHelper::Header.new([Post.new])
|
201
201
|
end
|
202
202
|
|
203
203
|
def test_should_display_if_hide_when_empty
|
204
204
|
@header.hide_when_empty = true
|
205
205
|
|
206
|
-
expected = <<-
|
206
|
+
expected = <<-end_str
|
207
207
|
<thead>
|
208
208
|
<tr>
|
209
209
|
<th class="title" scope="col">Title</th>
|
210
210
|
<th class="author_name" scope="col">Author Name</th>
|
211
211
|
</tr>
|
212
212
|
</thead>
|
213
|
-
|
213
|
+
end_str
|
214
214
|
assert_html_equal expected, @header.html
|
215
215
|
end
|
216
216
|
|
217
217
|
def test_should_display_if_not_hide_when_empty
|
218
218
|
@header.hide_when_empty = false
|
219
219
|
|
220
|
-
expected = <<-
|
220
|
+
expected = <<-end_str
|
221
221
|
<thead>
|
222
222
|
<tr>
|
223
223
|
<th class="title" scope="col">Title</th>
|
224
224
|
<th class="author_name" scope="col">Author Name</th>
|
225
225
|
</tr>
|
226
226
|
</thead>
|
227
|
-
|
227
|
+
end_str
|
228
228
|
assert_html_equal expected, @header.html
|
229
229
|
end
|
230
230
|
end
|