summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-06-10 01:42:10 -0500
committerSamuel Giddins <segiddins@segiddins.me>2016-06-10 12:56:14 -0500
commitc12b98c26b0e61d29b216d67c624e241748a6032 (patch)
tree71b747cbb6cbb1e63b428309d22dbe74cbc68798
parentfef20f71c22704e7915af7657804ae74e0a5a841 (diff)
downloadbundler-c12b98c26b0e61d29b216d67c624e241748a6032.tar.gz
[PostIt] Update to add legacy RubyGems support
-rw-r--r--lib/bundler/vendor/postit/lib/postit/installer.rb15
-rw-r--r--spec/other/trampoline_spec.rb4
2 files changed, 15 insertions, 4 deletions
diff --git a/lib/bundler/vendor/postit/lib/postit/installer.rb b/lib/bundler/vendor/postit/lib/postit/installer.rb
index 30a74a0190..6fc98560e7 100644
--- a/lib/bundler/vendor/postit/lib/postit/installer.rb
+++ b/lib/bundler/vendor/postit/lib/postit/installer.rb
@@ -5,13 +5,24 @@ module BundlerVendoredPostIt
end
def installed?
- !Gem::Specification.find_by_name('bundler', @bundler_version).nil?
+ if Gem::Specification.respond_to?(:find_by_name)
+ !Gem::Specification.find_by_name('bundler', @bundler_version).nil?
+ else
+ dep = Gem::Dependency.new('bundler', @bundler_version)
+ Gem.source_index.gems.values.any? do |s|
+ dep.match?(s.name, s.version)
+ end
+ end
rescue LoadError
false
end
def install!
- Gem.install('bundler', @bundler_version) unless installed?
+ return if installed?
+ require "rubygems/dependency_installer"
+ installer = Gem::DependencyInstaller.new
+ installer.install('bundler', @bundler_version)
+ installer.installed_gems
end
end
end
diff --git a/spec/other/trampoline_spec.rb b/spec/other/trampoline_spec.rb
index f172f62ac8..640c608508 100644
--- a/spec/other/trampoline_spec.rb
+++ b/spec/other/trampoline_spec.rb
@@ -82,10 +82,10 @@ describe "bundler version trampolining" do
it "fails gracefully when installing the bundler fails" do
ENV["BUNDLER_VERSION"] = "9999"
bundle "--version", :expect_err => true
- expect(err).to eq(<<-E.strip)
+ expect(err).to start_with(<<-E.strip)
Installing the inferred bundler version (= 9999) failed.
If you'd like to update to the current bundler version (1.12.5) in this project, run `bundle update --bundler`.
-The error was: Unable to resolve dependency: user requested 'bundler (= 9999)'
+The error was:
E
end
end