@@ -134,6 +134,88 @@ def test_generate
134
134
)
135
135
end
136
136
137
+ def test_generate_index_with_main_page
138
+ top_level = @store . add_file 'file.rb'
139
+ top_level . comment = <<~RDOC
140
+ = Heading 1
141
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
142
+ == Heading 1.1
143
+ tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
144
+ === Heading 1.1.1
145
+ quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
146
+ ==== Heading 1.1.1.1
147
+ consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
148
+ == Heading 1.2
149
+ cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
150
+ == Heading 1.3
151
+ non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
152
+ === Heading 1.3.1
153
+ etc etc...
154
+ RDOC
155
+
156
+ @options . main_page = 'file.rb'
157
+ @options . title = 'My awesome Ruby project'
158
+
159
+ @g . generate
160
+
161
+ assert_file 'index.html'
162
+ assert_file 'table_of_contents.html'
163
+ assert_file 'js/search_index.js'
164
+
165
+ assert_hard_link 'css/rdoc.css'
166
+ assert_hard_link 'css/fonts.css'
167
+
168
+ assert_hard_link 'fonts/SourceCodePro-Bold.ttf'
169
+ assert_hard_link 'fonts/SourceCodePro-Regular.ttf'
170
+
171
+ index_html = File . binread ( 'index.html' )
172
+
173
+ assert_include index_html , "<h3>Table of Contents</h3>"
174
+ assert_include index_html , '<h1 id="label-Heading+1">Heading 1'
175
+ # When there's a main page, the default description should not be shown
176
+ assert_not_include index_html , 'This is the API documentation for My awesome Ruby project.'
177
+ end
178
+
179
+ def test_generate_index_without_main_page
180
+ top_level = @store . add_file 'file.rb'
181
+ top_level . comment = <<~RDOC
182
+ = Heading 1
183
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
184
+ == Heading 1.1
185
+ tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
186
+ === Heading 1.1.1
187
+ quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
188
+ ==== Heading 1.1.1.1
189
+ consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
190
+ == Heading 1.2
191
+ cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
192
+ == Heading 1.3
193
+ non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
194
+ === Heading 1.3.1
195
+ etc etc...
196
+ RDOC
197
+
198
+ @options . title = 'My awesome Ruby project'
199
+
200
+ @g . generate
201
+
202
+ assert_file 'index.html'
203
+ assert_file 'table_of_contents.html'
204
+ assert_file 'js/search_index.js'
205
+
206
+ assert_hard_link 'css/rdoc.css'
207
+ assert_hard_link 'css/fonts.css'
208
+
209
+ assert_hard_link 'fonts/SourceCodePro-Bold.ttf'
210
+ assert_hard_link 'fonts/SourceCodePro-Regular.ttf'
211
+
212
+ index_html = File . binread ( 'index.html' )
213
+
214
+ # If there is no main page, the index page should not have a table of contents
215
+ assert_not_include index_html , "<h3>Table of Contents</h3>"
216
+ assert_include index_html , 'This is the API documentation for My awesome Ruby project.'
217
+ end
218
+
137
219
def test_generate_page
138
220
@store . add_file 'outer.rdoc' , parser : RDoc ::Parser ::Simple
139
221
@store . add_file 'outer/inner.rdoc' , parser : RDoc ::Parser ::Simple
0 commit comments