317d08
From 745899dec8f28d50a37dc03a96bbea972caaef58 Mon Sep 17 00:00:00 2001
317d08
From: SHIBATA Hiroshi <hsbt@ruby-lang.org>
317d08
Date: Tue, 19 Feb 2019 22:41:56 +0900
317d08
Subject: [PATCH] Use ENV["BUNDLE_GEM"] instead of gem command provided by
317d08
 system ruby.
317d08
317d08
  It break the examples of bundler. Because some examples detect the
317d08
  different version of system ruby than test target version like trunk.
317d08
---
317d08
 lib/bundler/gem_helper.rb            |  8 ++++++--
317d08
 spec/bundler/commands/clean_spec.rb  | 14 +++++++++-----
317d08
 spec/bundler/support/rubygems_ext.rb |  7 ++-----
317d08
 3 files changed, 17 insertions(+), 12 deletions(-)
317d08
317d08
diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb
317d08
index e7673cba88..c54259b5b6 100644
317d08
--- a/lib/bundler/gem_helper.rb
317d08
+++ b/lib/bundler/gem_helper.rb
317d08
@@ -74,7 +74,8 @@ def install
317d08
 
317d08
     def build_gem
317d08
       file_name = nil
317d08
-      sh("gem build -V '#{spec_path}'") do
317d08
+      gem = ENV["BUNDLE_GEM"] ? ENV["BUNDLE_GEM"] : "gem"
317d08
+      sh("#{gem} build -V #{spec_path}") do
317d08
         file_name = File.basename(built_gem_path)
317d08
         SharedHelpers.filesystem_access(File.join(base, "pkg")) {|p| FileUtils.mkdir_p(p) }
317d08
         FileUtils.mv(built_gem_path, "pkg")
317d08
@@ -85,7 +86,10 @@ def build_gem
317d08
 
317d08
     def install_gem(built_gem_path = nil, local = false)
317d08
       built_gem_path ||= build_gem
317d08
-      out, _ = sh_with_code("gem install '#{built_gem_path}'#{" --local" if local}")
317d08
+      gem = ENV["BUNDLE_GEM"] ? ENV["BUNDLE_GEM"] : "gem"
317d08
+      cmd = "#{gem} install #{built_gem_path}"
317d08
+      cmd = "#{cmd} --local" if local
317d08
+      out, _ = sh_with_code(cmd)
317d08
       raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output" unless out[/Successfully installed/]
317d08
       Bundler.ui.confirm "#{name} (#{version}) installed."
317d08
     end
317d08
diff --git a/spec/bundler/commands/clean_spec.rb b/spec/bundler/commands/clean_spec.rb
317d08
index 37cbeeb4e7..74a5b86ec1 100644
317d08
--- a/spec/bundler/commands/clean_spec.rb
317d08
+++ b/spec/bundler/commands/clean_spec.rb
317d08
@@ -339,7 +339,8 @@ def should_not_have_gems(*gems)
317d08
       gem "rack"
317d08
     G
317d08
 
317d08
-    sys_exec! "gem list"
317d08
+    gem = ruby_core? ? ENV["BUNDLE_GEM"] : "gem"
317d08
+    sys_exec! "#{gem} list"
317d08
     expect(out).to include("rack (1.0.0)").and include("thin (1.0)")
317d08
   end
317d08
 
317d08
@@ -461,8 +462,9 @@ def should_not_have_gems(*gems)
317d08
     end
317d08
     bundle! :update, :all => bundle_update_requires_all?
317d08
 
317d08
-    sys_exec! "gem list"
317d08
-    expect(out).to include("foo (1.0.1, 1.0)")
317d08
+    gem = ruby_core? ? ENV["BUNDLE_GEM"] : "gem"
317d08
+    sys_exec! "#{gem} list"
317d08
+  expect(out).to include("foo (1.0.1, 1.0)")
317d08
   end
317d08
 
317d08
   it "cleans system gems when --force is used" do
317d08
@@ -485,7 +487,8 @@ def should_not_have_gems(*gems)
317d08
     bundle "clean --force"
317d08
 
317d08
     expect(out).to include("Removing foo (1.0)")
317d08
-    sys_exec "gem list"
317d08
+    gem = ruby_core? ? ENV["BUNDLE_GEM"] : "gem"
317d08
+    sys_exec "#{gem} list"
317d08
     expect(out).not_to include("foo (1.0)")
317d08
     expect(out).to include("rack (1.0.0)")
317d08
   end
317d08
@@ -519,7 +522,8 @@ def should_not_have_gems(*gems)
317d08
       expect(out).to include(system_gem_path.to_s)
317d08
       expect(out).to include("grant write permissions")
317d08
 
317d08
-      sys_exec "gem list"
317d08
+      gem = ruby_core? ? ENV["BUNDLE_GEM"] : "gem"
317d08
+      sys_exec "#{gem} list"
317d08
       expect(out).to include("foo (1.0)")
317d08
       expect(out).to include("rack (1.0.0)")
317d08
     end
317d08
diff --git a/spec/bundler/support/rubygems_ext.rb b/spec/bundler/support/rubygems_ext.rb
317d08
index c18f7650fc..408d715ecf 100644
317d08
--- a/spec/bundler/support/rubygems_ext.rb
317d08
+++ b/spec/bundler/support/rubygems_ext.rb
317d08
@@ -59,11 +59,8 @@ def self.install_gems(gems)
317d08
       no_reqs.map!(&:first)
317d08
       reqs.map! {|name, req| "'#{name}:#{req}'" }
317d08
       deps = reqs.concat(no_reqs).join(" ")
317d08
-      cmd = if Gem::VERSION < "2.0.0"
317d08
-        "gem install #{deps} --no-rdoc --no-ri --conservative"
317d08
-      else
317d08
-        "gem install #{deps} --no-document --conservative"
317d08
-      end
317d08
+      gem = Spec::Path.ruby_core? ? ENV["BUNDLE_GEM"] : "#{Gem.ruby} -S gem"
317d08
+      cmd = "#{gem} install #{deps} --no-document --conservative"
317d08
       puts cmd
317d08
       system(cmd) || raise("Installing gems #{deps} for the tests to use failed!")
317d08
     end
317d08
-- 
317d08
2.31.1
317d08