summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2026-05-12 15:51:25 +0900
committergit <svn-admin@ruby-lang.org>2026-05-14 00:51:42 +0000
commitb28949c4df755caa0be23a22d7853bd1b6b5dd66 (patch)
treeba109bb45a94688f154948bd53a222ade493bc26 /test
parentb1a26097ad2af258d37c59524f5cf92070a4bb9b (diff)
[ruby/rubygems] Read BUNDLE_VERSION env var in BundlerVersionFinder
Bundler::Settings resolves the `version` setting from the BUNDLE_VERSION environment variable, but Gem::BundlerVersionFinder only consulted the .bundle/config file. As a result `BUNDLE_VERSION=system` was ignored at activation time and a lockfile-pinned bundler installed globally won out over the default gem. https://github.com/ruby/rubygems/issues/9534 https://github.com/ruby/rubygems/commit/c652c233aa
Diffstat (limited to 'test')
-rw-r--r--test/rubygems/test_gem_bundler_version_finder.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_bundler_version_finder.rb b/test/rubygems/test_gem_bundler_version_finder.rb
index 88ee9c6759..be8c5914f4 100644
--- a/test/rubygems/test_gem_bundler_version_finder.rb
+++ b/test/rubygems/test_gem_bundler_version_finder.rb
@@ -104,6 +104,48 @@ class TestGemBundlerVersionFinder < Gem::TestCase
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