diff options
author | Benoit Daloze <eregontp@gmail.com> | 2020-05-09 12:40:57 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-06-05 07:32:42 +0900 |
commit | ae3d0d8a20c74e8163957deddc30ac81e40be353 (patch) | |
tree | 67514fa0352aa11128f9930ec51e79fc2675a1c9 | |
parent | 345461018da1ba5a6aa5b14762e7d8d159f864c1 (diff) | |
download | ruby-ae3d0d8a20c74e8163957deddc30ac81e40be353.tar.gz |
[rubygems/rubygems] Add a more comprehensive and reliable test for upgraded default gems
* Test that the correct version is loaded and that the default gem is
not loaded at all.
https://github.com/rubygems/rubygems/commit/ee08508b2a
-rw-r--r-- | test/rubygems/test_require.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb index 9e66be51fa..7a460939a8 100644 --- a/test/rubygems/test_require.rb +++ b/test/rubygems/test_require.rb @@ -452,9 +452,31 @@ class TestGemRequire < Gem::TestCase puts Gem.loaded_specs["json"] RUBY output = Gem::Util.popen(*ruby_with_rubygems_in_load_path, "-e", cmd).strip + assert $?.success? refute_empty output end + def test_realworld_upgraded_default_gem + testing_ruby_repo = !ENV["GEM_COMMAND"].nil? + skip "this test can't work under ruby-core setup" if testing_ruby_repo + + newer_json = util_spec("json", "999.99.9", nil, ["lib/json.rb"]) + install_gem newer_json + + cmd = <<-RUBY + $stderr = $stdout + require "json" + puts Gem.loaded_specs["json"].version + puts $LOADED_FEATURES + RUBY + output = Gem::Util.popen({ 'GEM_HOME' => @gemhome }, *ruby_with_rubygems_in_load_path, "-e", cmd).strip + assert $?.success? + refute_empty output + assert_equal "999.99.9", output.lines[0].chomp + # Make sure only files from the newer json gem are loaded, and no files from the default json gem + assert_equal ["#{@gemhome}/gems/json-999.99.9/lib/json.rb"], output.lines.grep(%r{/gems/json-}).map(&:chomp) + end + def test_default_gem_and_normal_gem default_gem_spec = new_default_spec("default", "2.0.0.0", nil, "default/gem.rb") |