Skip to content

Commit

Permalink
Simulate default gems manually
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt committed Apr 18, 2024
1 parent 0d28fbd commit 0f34a74
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion bundler/spec/support/helpers.rb
Expand Up @@ -321,9 +321,20 @@ def install_gem(path, install_dir, default = false)
raise "OMG `#{path}` does not exist!" unless File.exist?(path)

args = "--no-document --ignore-dependencies --verbose --local --install-dir #{install_dir}"
args += " --default" if default

gem_command "install #{args} '#{path}'"

if default
gem = Pathname.new(path).basename.to_s.match(/(.*)\.gem/)[1]

# Revert Gem::Installer#write_spec and apply Gem::Installer#write_default_spec
FileUtils.mkdir_p File.join(install_dir, "specifications", "default")
File.rename File.join(install_dir, "specifications", gem + ".gemspec"),
File.join(install_dir, "specifications", "default", gem + ".gemspec")

# Revert Gem::Installer#write_cache_file
File.remove File.join(install_dir, "cache", gem + ".gem")
end
end

def with_built_bundler(version = nil, &block)
Expand Down

0 comments on commit 0f34a74

Please sign in to comment.