[rubygems/rubygems] Fix bundler binstub version selection
To mimic built-in rubygems behaviour, only thing that should be approximated is the lockfile version. Other alternatives like `BUNDLER_VERSION` should be respected exactly. https://github.com/rubygems/rubygems/commit/dbd667d4bc
This commit is contained in:
parent
90899c50c2
commit
4271f4aea5
@ -60,16 +60,16 @@ m = Module.new do
|
||||
Regexp.last_match(1)
|
||||
end
|
||||
|
||||
def bundler_version
|
||||
@bundler_version ||=
|
||||
def bundler_requirement
|
||||
@bundler_requirement ||=
|
||||
env_var_version || cli_arg_version ||
|
||||
lockfile_version
|
||||
bundler_requirement_for(lockfile_version)
|
||||
end
|
||||
|
||||
def bundler_requirement
|
||||
return "#{Gem::Requirement.default}.a" unless bundler_version
|
||||
def bundler_requirement_for(version)
|
||||
return "#{Gem::Requirement.default}.a" unless version
|
||||
|
||||
bundler_gem_version = Gem::Version.new(bundler_version)
|
||||
bundler_gem_version = Gem::Version.new(version)
|
||||
|
||||
requirement = bundler_gem_version.approximate_recommendation
|
||||
|
||||
|
@ -140,8 +140,15 @@ RSpec.describe "bundle binstubs <gem>" do
|
||||
it "runs the correct version of bundler" do
|
||||
sys_exec "bin/bundle install", :env => { "BUNDLER_VERSION" => "999.999.999" }, :raise_on_error => false
|
||||
expect(exitstatus).to eq(42)
|
||||
expect(err).to include("Activating bundler (~> 999.999) failed:").
|
||||
and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 999.999'`")
|
||||
expect(err).to include("Activating bundler (999.999.999) failed:").
|
||||
and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`")
|
||||
end
|
||||
|
||||
it "runs the correct version of bundler even if a higher version is installed" do
|
||||
system_gems "bundler-999.999.998", "bundler-999.999.999"
|
||||
|
||||
sys_exec "bin/bundle install", :env => { "BUNDLER_VERSION" => "999.999.998", "DEBUG" => "1" }, :raise_on_error => false
|
||||
expect(out).to include %(Using bundler 999.999.998\n)
|
||||
end
|
||||
end
|
||||
|
||||
@ -215,8 +222,8 @@ RSpec.describe "bundle binstubs <gem>" do
|
||||
it "calls through to the explicit bundler version" do
|
||||
sys_exec "bin/bundle update --bundler=999.999.999", :raise_on_error => false
|
||||
expect(exitstatus).to eq(42)
|
||||
expect(err).to include("Activating bundler (~> 999.999) failed:").
|
||||
and include("To install the version of bundler this project requires, run `gem install bundler -v '~> 999.999'`")
|
||||
expect(err).to include("Activating bundler (999.999.999) failed:").
|
||||
and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`")
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user