[前][次][番号順一覧][スレッド一覧]

ruby-changes:66565

From: Hiroshi <ko1@a...>
Date: Wed, 23 Jun 2021 11:06:16 +0900 (JST)
Subject: [ruby-changes:66565] c483aa8394 (master): [ruby/rdoc] Rwrite test-case for rubygems_hook without Gem::TestCase

https://git.ruby-lang.org/ruby.git/commit/?id=c483aa8394

From c483aa8394fc26e341666db66938b1d6fc2cbb8e Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Fri, 18 Jun 2021 09:51:23 +0900
Subject: [ruby/rdoc] Rwrite test-case for rubygems_hook without Gem::TestCase

https://github.com/ruby/rdoc/commit/f8d1087ce5
---
 test/rdoc/test_rdoc_rubygems_hook.rb | 38 +++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/test/rdoc/test_rdoc_rubygems_hook.rb b/test/rdoc/test_rdoc_rubygems_hook.rb
index 28a6f71..4ab7ff0 100644
--- a/test/rdoc/test_rdoc_rubygems_hook.rb
+++ b/test/rdoc/test_rdoc_rubygems_hook.rb
@@ -1,30 +1,30 @@ https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_rubygems_hook.rb#L1
 # frozen_string_literal: true
-require 'rubygems/test_case'
+require "rubygems"
+require "fileutils"
+require "tmpdir"
 require 'rdoc/rubygems_hook'
+require "test/unit"
 
-class TestRDocRubygemsHook < Gem::TestCase
-  unless method_defined?(:assert_path_exist)
-    alias assert_path_exist assert_path_exists
-  end
-  unless method_defined?(:assert_path_not_exist)
-    alias assert_path_not_exist refute_path_exists
-  end
-  unless method_defined?(:assert_raise)
-    alias assert_raise assert_raises
-  end
-
+class TestRDocRubygemsHook < Test::Unit::TestCase
   def setup
-    super
+    FileUtils.mkdir_p File.expand_path("tmp")
 
-    @a = util_spec 'a', 2 do |s|
+    @a = Gem::Specification.new do |s|
+      s.platform    = Gem::Platform::RUBY
+      s.name        = "a"
+      s.version     = 2
       s.rdoc_options = %w[--main MyTitle]
       s.extra_rdoc_files = %w[README]
     end
+    @tempdir = Dir.mktmpdir("test_rubygems_", File.expand_path("tmp"))
 
-    write_file File.join(@tempdir, 'lib', 'a.rb')
-    write_file File.join(@tempdir, 'README')
+    @a.instance_variable_set(:@doc_dir, File.join(@tempdir, "doc"))
+    @a.instance_variable_set(:@gem_dir, File.join(@tempdir, "a-2"))
+    @a.instance_variable_set(:@full_gem_path, File.join(@tempdir, "a-2"))
 
-    install_gem @a
+    FileUtils.mkdir_p File.join(@tempdir, 'a-2', 'lib')
+    FileUtils.touch   File.join(@tempdir, 'a-2', 'lib', 'a.rb')
+    FileUtils.touch   File.join(@tempdir, 'a-2', 'README')
 
     @hook = RDoc::RubygemsHook.new @a
 
@@ -33,8 +33,10 @@ class TestRDocRubygemsHook < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_rubygems_hook.rb#L33
     rescue Gem::DocumentError => e
       skip e.message
     end
+  end
 
-    Gem.configuration[:rdoc] = nil
+  def teardown
+    FileUtils.rm_rf File.expand_path("tmp")
   end
 
   def test_initialize
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]