Skip to content

Commit 060d1f8

Browse files
Merge pull request #7892 from rubygems/deivid-rodriguez/fix-gem-list-default-and-normal-gem
Fix `gem list` regression when a regular gem shadows a default one (cherry picked from commit 19b5bf4)
1 parent 5947d80 commit 060d1f8

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

lib/rubygems/query_utils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def show_local_gems(name, req = Gem::Requirement.default)
132132
version_matches = show_prereleases? || !s.version.prerelease?
133133

134134
name_matches && version_matches
135-
end
135+
end.uniq(&:full_name)
136136

137137
spec_tuples = specs.map do |spec|
138138
[spec.name_tuple, spec]

test/rubygems/test_gem_commands_list_command.rb

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ def setup
88
super
99

1010
@cmd = Gem::Commands::ListCommand.new
11+
end
1112

13+
def test_execute_installed
1214
spec_fetcher do |fetcher|
1315
fetcher.spec "c", 1
1416
end
1517

1618
@fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do
1719
raise Gem::RemoteFetcher::FetchError
1820
end
19-
end
2021

21-
def test_execute_installed
2222
@cmd.handle_options %w[c --installed]
2323

2424
assert_raise Gem::MockGemUi::SystemExitException do
@@ -30,4 +30,29 @@ def test_execute_installed
3030
assert_equal "true\n", @ui.output
3131
assert_equal "", @ui.error
3232
end
33+
34+
def test_execute_normal_gem_shadowing_default_gem
35+
c1_default = new_default_spec "c", 1
36+
install_default_gems c1_default
37+
38+
c1 = util_spec("c", 1) {|s| s.date = "2024-01-01" }
39+
install_gem c1
40+
41+
Gem::Specification.reset
42+
43+
@cmd.handle_options %w[c]
44+
45+
use_ui @ui do
46+
@cmd.execute
47+
end
48+
49+
expected = <<-EOF
50+
51+
*** LOCAL GEMS ***
52+
53+
c (1)
54+
EOF
55+
56+
assert_equal expected, @ui.output
57+
end
3358
end

0 commit comments

Comments
 (0)