1
1
# frozen_string_literal: true
2
- require 'rubygems/test_case'
2
+ require "rubygems"
3
+ require "fileutils"
4
+ require "tmpdir"
3
5
require 'rdoc/rubygems_hook'
6
+ require "test/unit"
4
7
5
- class TestRDocRubygemsHook < Gem ::TestCase
6
- unless method_defined? ( :assert_path_exist )
7
- alias assert_path_exist assert_path_exists
8
- end
9
- unless method_defined? ( :assert_path_not_exist )
10
- alias assert_path_not_exist refute_path_exists
11
- end
12
- unless method_defined? ( :assert_raise )
13
- alias assert_raise assert_raises
14
- end
15
-
8
+ class TestRDocRubygemsHook < Test ::Unit ::TestCase
16
9
def setup
17
- super
10
+ FileUtils . mkdir_p File . expand_path ( "tmp" )
18
11
19
- @a = util_spec 'a' , 2 do |s |
12
+ @a = Gem ::Specification . new do |s |
13
+ s . platform = Gem ::Platform ::RUBY
14
+ s . name = "a"
15
+ s . version = 2
20
16
s . rdoc_options = %w[ --main MyTitle ]
21
17
s . extra_rdoc_files = %w[ README ]
22
18
end
19
+ @tempdir = Dir . mktmpdir ( "test_rubygems_" , File . expand_path ( "tmp" ) )
23
20
24
- write_file File . join ( @tempdir , 'lib' , 'a.rb' )
25
- write_file File . join ( @tempdir , 'README' )
21
+ @a . instance_variable_set ( :@doc_dir , File . join ( @tempdir , "doc" ) )
22
+ @a . instance_variable_set ( :@gem_dir , File . join ( @tempdir , "a-2" ) )
23
+ @a . instance_variable_set ( :@full_gem_path , File . join ( @tempdir , "a-2" ) )
26
24
27
- install_gem @a
25
+ FileUtils . mkdir_p File . join ( @tempdir , 'a-2' , 'lib' )
26
+ FileUtils . touch File . join ( @tempdir , 'a-2' , 'lib' , 'a.rb' )
27
+ FileUtils . touch File . join ( @tempdir , 'a-2' , 'README' )
28
28
29
29
@hook = RDoc ::RubygemsHook . new @a
30
30
@@ -33,8 +33,10 @@ def setup
33
33
rescue Gem ::DocumentError => e
34
34
skip e . message
35
35
end
36
+ end
36
37
37
- Gem . configuration [ :rdoc ] = nil
38
+ def teardown
39
+ FileUtils . rm_rf File . expand_path ( "tmp" )
38
40
end
39
41
40
42
def test_initialize
0 commit comments