Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/rubygems/bundler_version_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

module Gem::BundlerVersionFinder
def self.bundler_version
return if bundle_config_version == "system"
bcv = bundle_config_version
return if bcv == "system"

v = ENV["BUNDLER_VERSION"]
v = nil if v&.empty?

v ||= bundle_update_bundler_version
return if v == true

v ||= bundle_config_version
v ||= bcv unless bcv == "lockfile"

v ||= lockfile_version
return unless v
Expand Down
25 changes: 25 additions & 0 deletions test/rubygems/test_gem_bundler_version_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,31 @@ def test_bundler_version_with_empty_bundle_version_env
end
end

def test_bundler_version_with_bundle_version_env_lockfile
ENV["BUNDLE_VERSION"] = "lockfile"

bvf.stub(:lockfile_contents, "\n\nBUNDLED WITH\n 1.1.1.1\n") do
assert_equal v("1.1.1.1"), bvf.bundler_version
end
end

def test_bundler_version_with_bundle_config_version_lockfile
config_content = <<~CONFIG
BUNDLE_VERSION: "lockfile"
CONFIG

Tempfile.create("bundle_config") do |f|
f.write(config_content)
f.flush

bvf.stub(:bundler_global_config_file, f.path) do
bvf.stub(:lockfile_contents, "\n\nBUNDLED WITH\n 1.1.1.1\n") do
assert_equal v("1.1.1.1"), bvf.bundler_version
end
end
end
end

def test_bundler_version_with_bundle_config_non_existent_file
bvf.stub(:bundler_global_config_file, "/non/existent/path") do
assert_nil bvf.bundler_version
Expand Down
Loading