@@ -32,7 +32,7 @@ def setup
32
32
end
33
33
34
34
def test_initialize
35
- assert @hook . generate_rdoc
35
+ refute @hook . generate_rdoc
36
36
assert @hook . generate_ri
37
37
38
38
rdoc = RDoc ::RubygemsHook . new @a , false , false
@@ -74,6 +74,27 @@ def test_generate
74
74
75
75
@hook . generate
76
76
77
+ refute @hook . rdoc_installed?
78
+ assert @hook . ri_installed?
79
+
80
+ rdoc = @hook . instance_variable_get :@rdoc
81
+
82
+ refute rdoc . options . hyperlink_all
83
+ assert_equal Pathname ( @a . full_gem_path ) , rdoc . options . root
84
+ assert_equal %w[ README lib ] , rdoc . options . files . sort
85
+
86
+ assert_equal 'MyTitle' , rdoc . store . main
87
+ end
88
+
89
+ def test_generate_all
90
+ @hook . generate_rdoc = true
91
+ @hook . generate_ri = true
92
+
93
+ FileUtils . mkdir_p @a . doc_dir
94
+ FileUtils . mkdir_p File . join ( @a . gem_dir , 'lib' )
95
+
96
+ @hook . generate
97
+
77
98
assert @hook . rdoc_installed?
78
99
assert @hook . ri_installed?
79
100
@@ -145,7 +166,7 @@ def test_generate_force
145
166
146
167
@hook . generate
147
168
148
- assert_path_exists File . join ( @a . doc_dir ( 'rdoc' ) , 'index.html' )
169
+ refute_path_exists File . join ( @a . doc_dir ( 'rdoc' ) , 'index.html' )
149
170
assert_path_exists File . join ( @a . doc_dir ( 'ri' ) , 'cache.ri' )
150
171
end
151
172
@@ -195,7 +216,7 @@ def test_remove_unwritable
195
216
196
217
assert_equal @a . base_dir , e . directory
197
218
ensure
198
- FileUtils . chmod 0755 , @a . base_dir
219
+ FileUtils . chmod ( 0755 , @a . base_dir ) if File . directory? ( @a . base_dir )
199
220
end
200
221
201
222
def test_ri_installed?
@@ -214,20 +235,18 @@ def test_setup
214
235
215
236
def test_setup_unwritable
216
237
skip 'chmod not supported' if Gem . win_platform?
217
- begin
218
- FileUtils . mkdir_p @a . doc_dir
219
- FileUtils . chmod 0 , @a . doc_dir
220
-
221
- e = assert_raises Gem ::FilePermissionError do
222
- @hook . setup
223
- end
224
-
225
- assert_equal @a . doc_dir , e . directory
226
- ensure
227
- if File . exist? @a . doc_dir
228
- FileUtils . chmod 0755 , @a . doc_dir
229
- FileUtils . rm_r @a . doc_dir
230
- end
238
+ FileUtils . mkdir_p @a . doc_dir
239
+ FileUtils . chmod 0 , @a . doc_dir
240
+
241
+ e = assert_raises Gem ::FilePermissionError do
242
+ @hook . setup
243
+ end
244
+
245
+ assert_equal @a . doc_dir , e . directory
246
+ ensure
247
+ if File . exist? @a . doc_dir
248
+ FileUtils . chmod 0755 , @a . doc_dir
249
+ FileUtils . rm_r @a . doc_dir
231
250
end
232
251
end
233
252
0 commit comments