diff options
Diffstat (limited to 'test/rubygems/test_gem.rb')
-rw-r--r-- | test/rubygems/test_gem.rb | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index b2f718bf1a..ad802e0f95 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -155,8 +155,10 @@ class TestGem < Gem::TestCase def test_self_install_permissions_with_format_executable_and_non_standard_ruby_install_name Gem::Installer.exec_format = nil - ruby_install_name 'ruby27' do - assert_self_install_permissions(format_executable: true) + with_clean_path_to_ruby do + ruby_install_name 'ruby27' do + assert_self_install_permissions(format_executable: true) + end end ensure Gem::Installer.exec_format = nil @@ -553,7 +555,7 @@ class TestGem < Gem::TestCase Gem.ensure_gem_subdirectories @gemhome, 0750 - assert File.directory? File.join(@gemhome, "cache") + assert_directory_exists File.join(@gemhome, "cache") assert_equal 0750, File::Stat.new(@gemhome).mode & 0777 assert_equal 0750, File::Stat.new(File.join(@gemhome, "cache")).mode & 0777 @@ -582,7 +584,7 @@ class TestGem < Gem::TestCase Gem.ensure_gem_subdirectories gemdir - assert File.directory?(util_cache_dir) + assert_directory_exists util_cache_dir end unless win_platform? || Process.uid.zero? # only for FS that support write protection @@ -952,40 +954,36 @@ class TestGem < Gem::TestCase end def test_self_ruby_escaping_spaces_in_path - orig_ruby = Gem.ruby orig_bindir = RbConfig::CONFIG['bindir'] - orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name'] orig_exe_ext = RbConfig::CONFIG['EXEEXT'] RbConfig::CONFIG['bindir'] = "C:/Ruby 1.8/bin" - RbConfig::CONFIG['ruby_install_name'] = "ruby" RbConfig::CONFIG['EXEEXT'] = ".exe" - Gem.instance_variable_set("@ruby", nil) - assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby + ruby_install_name "ruby" do + with_clean_path_to_ruby do + assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby + end + end ensure - Gem.instance_variable_set("@ruby", orig_ruby) RbConfig::CONFIG['bindir'] = orig_bindir - RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name RbConfig::CONFIG['EXEEXT'] = orig_exe_ext end def test_self_ruby_path_without_spaces - orig_ruby = Gem.ruby orig_bindir = RbConfig::CONFIG['bindir'] - orig_ruby_install_name = RbConfig::CONFIG['ruby_install_name'] orig_exe_ext = RbConfig::CONFIG['EXEEXT'] RbConfig::CONFIG['bindir'] = "C:/Ruby18/bin" - RbConfig::CONFIG['ruby_install_name'] = "ruby" RbConfig::CONFIG['EXEEXT'] = ".exe" - Gem.instance_variable_set("@ruby", nil) - assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby + ruby_install_name "ruby" do + with_clean_path_to_ruby do + assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby + end + end ensure - Gem.instance_variable_set("@ruby", orig_ruby) RbConfig::CONFIG['bindir'] = orig_bindir - RbConfig::CONFIG['ruby_install_name'] = orig_ruby_install_name RbConfig::CONFIG['EXEEXT'] = orig_exe_ext end @@ -1904,6 +1902,16 @@ You may need to `gem install -g` to install missing gems end end + def with_clean_path_to_ruby + orig_ruby = Gem.ruby + + Gem.instance_variable_set :@ruby, nil + + yield + ensure + Gem.instance_variable_set("@ruby", orig_ruby) + end + def with_plugin(path) test_plugin_path = File.expand_path("test/rubygems/plugin/#{path}", @@project_dir) |