Fix gemspec filename mismatches in stub helper methods#9467
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates Rubygems stub-spec test helpers so the gemspec filenames match the gem name declared inside the stub content, reducing confusion and avoiding potential lookup mismatches during debugging.
Changes:
- Renamed the gemspec path written by
stub_with_versionto usestub_v-2.gemspec. - Renamed the gemspec path written by
stub_without_versionto usestub_v-2.gemspec.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| def stub_with_version | ||
| spec = File.join @gemhome, "specifications", "stub_e-2.gemspec" | ||
| spec = File.join @gemhome, "specifications", "stub_v-2.gemspec" |
There was a problem hiding this comment.
stub_with_version now writes to stub_v-2.gemspec, but stub_without_version writes to the exact same path. Because these helpers generate different gemspec contents, calling both in the same test (or reusing helpers in new tests) would overwrite the earlier stub and make failures confusing. Use distinct filenames per helper (while still matching the gem name), e.g. keep stub_v-2.gemspec here and give the no-version helper a different name like stub_v-noversion.gemspec (or similar).
| spec = File.join @gemhome, "specifications", "stub_v-2.gemspec" | |
| spec = File.join @gemhome, "specifications", "stub_v-with-version.gemspec" |
|
|
||
| def stub_without_version | ||
| spec = File.join @gemhome, "specifications", "stub-2.gemspec" | ||
| spec = File.join @gemhome, "specifications", "stub_v-2.gemspec" |
There was a problem hiding this comment.
This helper writes to stub_v-2.gemspec, which is also used by stub_with_version. Since the two helpers create different gemspec stubs, sharing a filename can cause accidental overwrites if both helpers are used in the same test or future refactors. Consider using a distinct filename for the no-version case (still prefixed with stub_v to match the gem name).
| spec = File.join @gemhome, "specifications", "stub_v-2.gemspec" | |
| spec = File.join @gemhome, "specifications", "stub_v-without-version.gemspec" |
|
@copilot apply changes based on the comments in this thread |
Applied in e06bef0 — |
…thout_version Agent-Logs-Url: https://github.com/ruby/rubygems/sessions/8de78edb-b0d3-4fd3-bdad-898184561abd Co-authored-by: hsbt <12301+hsbt@users.noreply.github.com>
…version helpers Agent-Logs-Url: https://github.com/ruby/rubygems/sessions/4028db0e-e050-48af-9704-4219653a4753 Co-authored-by: hsbt <12301+hsbt@users.noreply.github.com>
e06bef0 to
a8f84a5
Compare
What was the end-user or developer problem that led to this PR?
In
test_gem_stub_specification.rb, two stub helper methods used gemspec filenames that didn't match the gem name defined in their stub content:stub_with_versionwrote tostub_e-2.gemspecbut declared gem namestub_vstub_without_versionwrote tostub-2.gemspecbut declared gem namestub_vAdditionally, both helpers were originally updated to share the same filename (
stub_v-2.gemspec), which could cause accidental overwrites if both helpers are used in the same test.What is your fix for the problem, implemented in this PR?
Rename the gemspec files in both helpers to match their gem names and use distinct filenames to avoid collisions:
stub_e-2.gemspec→stub_v-with-version.gemspecinstub_with_versionstub-2.gemspec→stub_v-without-version.gemspecinstub_without_versionBoth filenames are now prefixed with
stub_vto match the gem name, while remaining distinct to prevent accidental overwrites when both helpers are used in the same test or future refactors.Note:
stub_with_extension(stub_e-2.gemspecfor gemstub_e) andstub_without_extension(stub-2.gemspecfor gemstub) are correct and unchanged.Make sure the following tasks are checked
Original prompt