Skip to content

Fix gemspec filename mismatches in stub helper methods#9467

Merged
hsbt merged 2 commits intomasterfrom
copilot/fix-stub-file-name-consistency
Apr 8, 2026
Merged

Fix gemspec filename mismatches in stub helper methods#9467
hsbt merged 2 commits intomasterfrom
copilot/fix-stub-file-name-consistency

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

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_version wrote to stub_e-2.gemspec but declared gem name stub_v
  • stub_without_version wrote to stub-2.gemspec but declared gem name stub_v

Additionally, 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.gemspecstub_v-with-version.gemspec in stub_with_version
  • stub-2.gemspecstub_v-without-version.gemspec in stub_without_version

Both filenames are now prefixed with stub_v to 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.gemspec for gem stub_e) and stub_without_extension (stub-2.gemspec for gem stub) are correct and unchanged.

Make sure the following tasks are checked

Original prompt
Please apply the following diffs and create a pull request.
Once the PR is ready, give it a title based on the messages of the fixes being applied.

[{"message":"The filename 'stub_e-2.gemspec' in stub_with_version method doesn't match the gem name 'stub_v' defined in the stub content. This inconsistency could lead to confusion or potential file system issues. Consider renaming the file to 'stub_v-2.gemspec' to match the gem name.","fixFiles":[{"filePath":"test/rubygems/test_gem_stub_specification.rb","diff":"diff --git a/test/rubygems/test_gem_stub_specification.rb b/test/rubygems/test_gem_stub_specification.rb\n--- a/test/rubygems/test_gem_stub_specification.rb\n+++ b/test/rubygems/test_gem_stub_specification.rb\n@@ -221,7 +221,7 @@\n   end\n \n   def stub_with_version\n-    spec = File.join @gemhome, \"specifications\", \"stub_e-2.gemspec\"\n+    spec = File.join @gemhome, \"specifications\", \"stub_v-2.gemspec\"\n     File.open spec, \"w\" do |io|\n       io.write <<~STUB\n         # -*- encoding: utf-8 -*-\n"}]},{"message":"The filename 'stub-2.gemspec' in stub_without_version method doesn't match the gem name 'stub_v' defined in the stub content. This inconsistency could cause file lookup issues. The filename should be 'stub_v-2.gemspec' to match the gem name in the stubline.","fixFiles":[{"filePath":"test/rubygems/test_gem_stub_specification.rb","diff":"diff --git a/test/rubygems/test_gem_stub_specification.rb b/test/rubygems/test_gem_stub_specification.rb\n--- a/test/rubygems/test_gem_stub_specification.rb\n+++ b/test/rubygems/test_gem_stub_specification.rb\n@@ -244,7 +244,7 @@\n   end\n \n   def stub_without_version\n-    spec = File.join @gemhome, \"specifications\", \"stub-2.gemspec\"\n+    spec = File.join @gemhome, \"specifications\", \"stub_v-2.gemspec\"\n     File.open spec, \"w\" do |io|\n       io.write <<~STUB\n         # -*- encoding: utf-8 -*-\n"}]}]

Copilot AI assigned Copilot and hsbt Apr 8, 2026
Copilot AI changed the title [WIP] Fix filename inconsistency in stub_with_version method Fix gemspec filename mismatches in stub helper methods Apr 8, 2026
Copilot AI requested a review from hsbt April 8, 2026 03:55
Copilot finished work on behalf of hsbt April 8, 2026 03:55
@hsbt hsbt marked this pull request as ready for review April 8, 2026 03:56
Copilot AI review requested due to automatic review settings April 8, 2026 03:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_version to use stub_v-2.gemspec.
  • Renamed the gemspec path written by stub_without_version to use stub_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"
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
spec = File.join @gemhome, "specifications", "stub_v-2.gemspec"
spec = File.join @gemhome, "specifications", "stub_v-with-version.gemspec"

Copilot uses AI. Check for mistakes.

def stub_without_version
spec = File.join @gemhome, "specifications", "stub-2.gemspec"
spec = File.join @gemhome, "specifications", "stub_v-2.gemspec"
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
spec = File.join @gemhome, "specifications", "stub_v-2.gemspec"
spec = File.join @gemhome, "specifications", "stub_v-without-version.gemspec"

Copilot uses AI. Check for mistakes.
@hsbt
Copy link
Copy Markdown
Member

hsbt commented Apr 8, 2026

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 8, 2026

@copilot apply changes based on the comments in this thread

Applied in e06bef0stub_with_version now uses stub_v-with-version.gemspec and stub_without_version uses stub_v-without-version.gemspec, giving each helper a distinct filename while still matching the gem name.

Copilot finished work on behalf of hsbt April 8, 2026 04:37
@hsbt hsbt force-pushed the copilot/fix-stub-file-name-consistency branch from e06bef0 to a8f84a5 Compare April 8, 2026 04:39
@hsbt hsbt merged commit 951ef62 into master Apr 8, 2026
94 checks passed
@hsbt hsbt deleted the copilot/fix-stub-file-name-consistency branch April 8, 2026 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants