From 57404e4369df11f77f089d5d11d310679b2e749f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 10 Oct 2024 20:50:48 +0200 Subject: [PATCH] [rubygems/rubygems] Fix duplicated specs when they have been previously activated https://github.com/rubygems/rubygems/commit/b44bf2ac74 --- lib/rubygems/specification_record.rb | 2 +- test/rubygems/test_gem.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/rubygems/specification_record.rb b/lib/rubygems/specification_record.rb index d838fcea26..195a355496 100644 --- a/lib/rubygems/specification_record.rb +++ b/lib/rubygems/specification_record.rb @@ -30,7 +30,7 @@ module Gem # Returns the list of all specifications in the record def all - @all ||= Gem.loaded_specs.values + stubs.map(&:to_spec) + @all ||= stubs.map(&:to_spec) end ## diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index 0d048b08b7..cdc3479e37 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -1026,6 +1026,20 @@ class TestGem < Gem::TestCase Gem.refresh end + def test_activated_specs_does_not_cause_duplicates_when_looping_through_specs + util_make_gems + + s = Gem::Specification.first + s.activate + + Gem.refresh + + assert_equal 1, Gem::Specification.count {|spec| spec.full_name == s.full_name } + + Gem.loaded_specs.delete(s) + Gem.refresh + end + def test_self_ruby_escaping_spaces_in_path with_clean_path_to_ruby do with_rb_config_ruby("C:/Ruby 1.8/bin/ruby.exe") do