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
3 changes: 3 additions & 0 deletions lib/rubygems/bundler_version_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ def self.lockfile_contents
private_class_method :lockfile_contents

def self.bundle_config_version
env_version = ENV["BUNDLE_VERSION"]
return env_version if env_version && !env_version.empty?

Comment on lines 72 to +75
version = nil

[bundler_local_config_file, bundler_global_config_file].each do |config_file|
Expand Down
42 changes: 42 additions & 0 deletions test/rubygems/test_gem_bundler_version_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,48 @@ def test_bundler_version_with_bundle_config_version
end
end

def test_bundler_version_with_bundle_version_env_system
ENV["BUNDLE_VERSION"] = "system"

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

def test_bundler_version_with_bundle_version_env_overrides_config
ENV["BUNDLE_VERSION"] = "2.3.4"

config_content = <<~CONFIG
BUNDLE_VERSION: "1.2.3"
CONFIG

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

bvf.stub(:bundler_global_config_file, f.path) do
assert_equal v("2.3.4"), bvf.bundler_version
end
end
end

def test_bundler_version_with_empty_bundle_version_env
ENV["BUNDLE_VERSION"] = ""

config_content = <<~CONFIG
BUNDLE_VERSION: "1.2.3"
CONFIG

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

bvf.stub(:bundler_global_config_file, f.path) do
assert_equal v("1.2.3"), bvf.bundler_version
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