mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Autoswitch to exact bundler version if present
https://github.com/rubygems/rubygems/commit/bb02953a97
This commit is contained in:
parent
3587824d71
commit
5998012a0c
3 changed files with 40 additions and 1 deletions
|
@ -45,6 +45,11 @@ To install the missing version, run `gem install bundler:#{vr.first}`
|
|||
return unless bundler_version = self.bundler_version
|
||||
|
||||
specs.reject! { |spec| spec.version.segments.first != bundler_version.segments.first }
|
||||
|
||||
exact_match_index = specs.find_index { |spec| spec.version == bundler_version }
|
||||
return specs unless exact_match_index
|
||||
|
||||
specs.unshift(specs.delete_at(exact_match_index))
|
||||
end
|
||||
|
||||
def self.bundle_update_bundler_version
|
||||
|
|
|
@ -341,6 +341,40 @@ class TestGem < Gem::TestCase
|
|||
refute_includes e.message, "can't find gem bundler (>= 0.a) with executable bundle"
|
||||
end
|
||||
|
||||
def test_activate_bin_path_selects_exact_bundler_version_if_present
|
||||
bundler_latest = util_spec 'bundler', '2.0.1' do |s|
|
||||
s.executables = ['bundle']
|
||||
end
|
||||
|
||||
bundler_previous = util_spec 'bundler', '2.0.0' do |s|
|
||||
s.executables = ['bundle']
|
||||
end
|
||||
|
||||
install_specs bundler_latest, bundler_previous
|
||||
|
||||
File.open("Gemfile.lock", "w") do |f|
|
||||
f.write <<-L.gsub(/ {8}/, "")
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
|
||||
BUNDLED WITH
|
||||
2.0.0
|
||||
L
|
||||
end
|
||||
|
||||
File.open("Gemfile", "w") { |f| f.puts('source "https://rubygems.org"') }
|
||||
|
||||
load Gem.activate_bin_path("bundler", "bundle", ">= 0.a")
|
||||
|
||||
assert_equal %w(bundler-2.0.0), loaded_spec_names
|
||||
end
|
||||
|
||||
def test_self_bin_path_no_exec_name
|
||||
e = assert_raises ArgumentError do
|
||||
Gem.bin_path 'a'
|
||||
|
|
|
@ -116,7 +116,7 @@ class TestGemBundlerVersionFinder < Gem::TestCase
|
|||
assert_equal %w[1 1.0 1.0.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
|
||||
end
|
||||
bvf.stub(:bundler_version, v("2.a")) do
|
||||
assert_equal %w[2 2.a 2.0 2.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
|
||||
assert_equal %w[2.a 2 2.0 2.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
|
||||
end
|
||||
bvf.stub(:bundler_version, v("3")) do
|
||||
assert_equal %w[3 3.a 3.0 3.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
|
||||
|
|
Loading…
Add table
Reference in a new issue