Skip to content

Commit f8d1087

Browse files
committed
Rwrite test-case for rubygems_hook without Gem::TestCase
1 parent ebe185c commit f8d1087

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

test/rdoc/test_rdoc_rubygems_hook.rb

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
# frozen_string_literal: true
2-
require 'rubygems/test_case'
2+
require "rubygems"
3+
require "fileutils"
4+
require "tmpdir"
35
require 'rdoc/rubygems_hook'
6+
require "test/unit"
47

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
169
def setup
17-
super
10+
FileUtils.mkdir_p File.expand_path("tmp")
1811

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
2016
s.rdoc_options = %w[--main MyTitle]
2117
s.extra_rdoc_files = %w[README]
2218
end
19+
@tempdir = Dir.mktmpdir("test_rubygems_", File.expand_path("tmp"))
2320

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"))
2624

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')
2828

2929
@hook = RDoc::RubygemsHook.new @a
3030

@@ -33,8 +33,10 @@ def setup
3333
rescue Gem::DocumentError => e
3434
skip e.message
3535
end
36+
end
3637

37-
Gem.configuration[:rdoc] = nil
38+
def teardown
39+
FileUtils.rm_rf File.expand_path("tmp")
3840
end
3941

4042
def test_initialize

0 commit comments

Comments
 (0)