From f28be7e02d113bd26c33cb94e65004055576c065 Mon Sep 17 00:00:00 2001 From: hsbt Date: Tue, 2 Apr 2019 11:48:18 +0000 Subject: Merge rubygems/rubygems from upstream. The current master branch is https://github.com/rubygems/rubygems/commit/97b264f0fa248c864b6ee9a23d3ff1cdd217dddb git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rubygems/test_gem.rb | 49 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'test/rubygems/test_gem.rb') diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index ad802e0f95..abf7092991 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -954,37 +954,23 @@ class TestGem < Gem::TestCase end def test_self_ruby_escaping_spaces_in_path - orig_bindir = RbConfig::CONFIG['bindir'] - orig_exe_ext = RbConfig::CONFIG['EXEEXT'] - - RbConfig::CONFIG['bindir'] = "C:/Ruby 1.8/bin" - RbConfig::CONFIG['EXEEXT'] = ".exe" - - ruby_install_name "ruby" do - with_clean_path_to_ruby do - assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby + with_clean_path_to_ruby do + with_bindir_and_exeext("C:/Ruby 1.8/bin", ".exe") do + ruby_install_name "ruby" do + assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby + end end end - ensure - RbConfig::CONFIG['bindir'] = orig_bindir - RbConfig::CONFIG['EXEEXT'] = orig_exe_ext end def test_self_ruby_path_without_spaces - orig_bindir = RbConfig::CONFIG['bindir'] - orig_exe_ext = RbConfig::CONFIG['EXEEXT'] - - RbConfig::CONFIG['bindir'] = "C:/Ruby18/bin" - RbConfig::CONFIG['EXEEXT'] = ".exe" - - ruby_install_name "ruby" do - with_clean_path_to_ruby do - assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby + with_clean_path_to_ruby do + with_bindir_and_exeext("C:/Ruby18/bin", ".exe") do + ruby_install_name "ruby" do + assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby + end end end - ensure - RbConfig::CONFIG['bindir'] = orig_bindir - RbConfig::CONFIG['EXEEXT'] = orig_exe_ext end def test_self_ruby_api_version @@ -1902,6 +1888,19 @@ You may need to `gem install -g` to install missing gems end end + def with_bindir_and_exeext(bindir, exeext) + orig_bindir = RbConfig::CONFIG['bindir'] + orig_exe_ext = RbConfig::CONFIG['EXEEXT'] + + RbConfig::CONFIG['bindir'] = bindir + RbConfig::CONFIG['EXEEXT'] = exeext + + yield + ensure + RbConfig::CONFIG['bindir'] = orig_bindir + RbConfig::CONFIG['EXEEXT'] = orig_exe_ext + end + def with_clean_path_to_ruby orig_ruby = Gem.ruby @@ -1909,7 +1908,7 @@ You may need to `gem install -g` to install missing gems yield ensure - Gem.instance_variable_set("@ruby", orig_ruby) + Gem.instance_variable_set :@ruby, orig_ruby end def with_plugin(path) -- cgit v1.2.3