[rubygems/rubygems] Improve source list management testing

This approach better simulate that ["http://gems.example.com/"] is the
default list of sources, rather than ["https://rubygems.org/"].

https://github.com/rubygems/rubygems/commit/55130c259a
This commit is contained in:
David Rodríguez 2025-08-06 19:38:03 +02:00 committed by Hiroshi SHIBATA
parent 2d3fd1fd28
commit cbd0de84f6
3 changed files with 6 additions and 2 deletions

View File

@ -13,7 +13,7 @@ module Gem
# An Array of the default sources that come with RubyGems
def self.default_sources
%w[https://rubygems.org/]
@default_sources ||= %w[https://rubygems.org/]
end
##

View File

@ -400,8 +400,9 @@ class Gem::TestCase < Test::Unit::TestCase
Gem::RemoteFetcher.fetcher = Gem::FakeFetcher.new
@gem_repo = "http://gems.example.com/"
Gem.instance_variable_set :@default_sources, [@gem_repo]
Gem.instance_variable_set :@sources, nil
@uri = Gem::URI.parse @gem_repo
Gem.sources.replace [@gem_repo]
Gem.searcher = nil
Gem::SpecFetcher.fetcher = nil

View File

@ -586,6 +586,7 @@ class TestGem < Gem::TestCase
end
def test_self_default_sources
Gem.remove_instance_variable :@default_sources
assert_equal %w[https://rubygems.org/], Gem.default_sources
end
@ -1198,6 +1199,8 @@ class TestGem < Gem::TestCase
Gem.sources = nil
Gem.configuration.sources = %w[http://test.example.com/]
assert_equal %w[http://test.example.com/], Gem.sources
ensure
Gem.configuration.sources = nil
end
def test_try_activate_returns_true_for_activated_specs