diff options
| author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2024-04-18 15:59:19 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2025-10-28 11:06:16 +0000 |
| commit | ceb2b569af29ae515042c5fbab533e003ac42a4d (patch) | |
| tree | 254043cb4f847be52a418c66ebaa5d289fa1d64e | |
| parent | d67aba8a5d81383880e05504de9a52ab6b2a015e (diff) | |
[ruby/rubygems] Added install_default_gem method for testing
https://github.com/ruby/rubygems/commit/81dbd42abf
| -rw-r--r-- | test/rubygems/helper.rb | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb index ecd92b0a57..53bed0b415 100644 --- a/test/rubygems/helper.rb +++ b/test/rubygems/helper.rb @@ -60,6 +60,44 @@ class Gem::Command end end +class Gem::Installer + # Copy from Gem::Installer#install with install_as_default option from old version + def install_default_gem + pre_install_checks + + run_pre_install_hooks + + spec.loaded_from = default_spec_file + + FileUtils.rm_rf gem_dir + FileUtils.rm_rf spec.extension_dir + + dir_mode = options[:dir_mode] + FileUtils.mkdir_p gem_dir, mode: dir_mode && 0o755 + + extract_bin + write_default_spec + + generate_bin + generate_plugins + + File.chmod(dir_mode, gem_dir) if dir_mode + + say spec.post_install_message if options[:post_install_message] && !spec.post_install_message.nil? + + Gem::Specification.add_spec(spec) + + load_plugin + + run_post_install_hooks + + spec + rescue Errno::EACCES => e + # Permission denied - /path/to/foo + raise Gem::FilePermissionError, e.message.split(" - ").last + end +end + ## # RubyGemTestCase provides a variety of methods for testing rubygems and # gem-related behavior in a sandbox. Through RubyGemTestCase you can install @@ -812,7 +850,7 @@ class Gem::TestCase < Test::Unit::TestCase def install_default_gems(*specs) specs.each do |spec| installer = Gem::Installer.for_spec(spec) - installer.install + installer.install_default_gem Gem.register_default_spec(spec) end end |
