Skip to content

Commit

Permalink
! Add test and fix installer dep finding bug
Browse files Browse the repository at this point in the history
The previous commit removed changing the global paths when doing an
install, which caused the installer to not be able to find gems inside
the install directory. This test for some reason didn't fail though.
  • Loading branch information
evanphx committed Dec 20, 2011
1 parent 0c7e74c commit 44eb821
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
19 changes: 19 additions & 0 deletions lib/rubygems/installer.rb
Expand Up @@ -285,6 +285,24 @@ def install
raise Gem::InstallError, "gzip error installing #{gem}"
end

##
#
# Return an Array of Specifications contained within the gem_home
# we'll be installing into.

def installed_specs
@specs ||= begin
specs = []

Dir[File.join(gem_home, "specifications", "*.gemspec")].each do |path|
spec = Gem::Specification.load path.untaint
specs << spec if spec
end

specs
end
end

##
# Ensure that the dependency is satisfied by the current installation of
# gem. If it is not an exception is raised.
Expand All @@ -303,6 +321,7 @@ def ensure_dependency(spec, dependency)
# True if the gems in the source_index satisfy +dependency+.

def installation_satisfies_dependency?(dependency)
return true if installed_specs.detect { |s| dependency.matches_spec? s }
not dependency.matching_specs.empty?
end

Expand Down
8 changes: 5 additions & 3 deletions test/rubygems/test_gem_installer.rb
Expand Up @@ -791,13 +791,15 @@ def test_install_check_dependencies

def test_install_check_dependencies_install_dir
gemhome2 = "#{@gemhome}2"
@spec.add_dependency 'b'
@spec.add_dependency 'd'

quick_gem 'b', 2
quick_gem 'd', 2

FileUtils.mv @gemhome, gemhome2

Gem::Specification.dirs = [gemhome2] # TODO: switch all dirs= to use_paths
# Don't leak any already activated gems into the installer, require
# that it work everything out on it's own.
Gem::Specification.reset

util_setup_gem

Expand Down

0 comments on commit 44eb821

Please sign in to comment.