Skip to content

Find the RSpec spec for a Rails file in pregate lanes - #4211

Closed
ikraamg wants to merge 1 commit into
garrytan:mainfrom
ikraamg:pregate-rspec-convention
Closed

ikraamg wants to merge 1 commit into
garrytan:mainfrom
ikraamg:pregate-rspec-convention

Conversation

@ikraamg

@ikraamg ikraamg commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Rails loads classes by name, so a spec never requires the file it tests, and pregate gave every app/ file in a Rails repo no test lane.

  • A spec at spec/<path>_spec.rb now selects app/<path>.rb, and spec/lib/<path>_spec.rb selects lib/<path>.rb, when that file exists. It sits beside the existing bin/<name> convention.
  • Example from a real Rails app: touching app/services/plugins/netatmo_weather_station/api.rb used to report no lane, and the starter drafted 10+ unrelated specs that mention "api". It now selects spec/services/plugins/netatmo_weather_station/api_spec.rb (convention).
  • Test: test/pregate-rspec-convention.test.ts, including the case where no spec exists.

🤖 Generated with Claude Code

Rails loads classes by name, so no require or quoted path links
app/models/user.rb to spec/models/user_spec.rb. In a Rails repo every
app/ file had no test lane, and the starter draft matched specs by
name fragments instead (api.rb drafted every spec that mentions "api").

A spec at spec/<path>_spec.rb now selects app/<path>.rb and <path>.rb
(so spec/lib/x_spec.rb selects lib/x.rb) when that file exists, beside
the existing bin/ convention.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trunk-io

trunk-io Bot commented Nov 9, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@capy-ai

capy-ai Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Thanks @ikraamg. The idea sits naturally next to pregate's existing bin/<name> and Django conventions, and the spec-to-source mapping is small. We're picking it up for a crew rewrite on current main, crediting you as co-author. Pre-merge-check tooling is in a short freeze until Nov 21, so it will start after that.

@capy-ai

capy-ai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Thank you for this. We're picking up the idea. A maintainer agent working through a batch of fixes (our tracking thread GSTA-805) will first reproduce the problem on current main. If it reproduces, the agent rebuilds the fix on main with you credited as co-author, because we don't merge outside branches directly, and we'll close this PR with a link when it lands. If it no longer reproduces, we'll close this and say what changed. Other work on the same pregate files has to land first, so this may take a few days.

garrytan added a commit that referenced this pull request Nov 22, 2026
Test selection now follows a TypeScript import written with the emitted
extension (./x.js for x.ts) to its source, and maps a Rails file under app/
or lib/ to its RSpec spec by path, so these files no longer report no test
lane. Fixes #4398; rebuilt from #4401 and #4211.

Co-authored-by: mikhailsal <[email protected]>
Co-authored-by: Ikraam Ghoor <[email protected]>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
capy-ai Bot added a commit that referenced this pull request Nov 22, 2026
…4679)

In TypeScript repos that import `./x.js` for `x.ts` (NodeNext) and in
Rails repos, touched source files now get their tests instead of none.

Why: `/verify` and `/ship` found no tests for these files even though
tests covered the files (#4398, #4211).

Nothing to do: a Rails file maps only when its spec exists at the
conventional path.

Co-authored-by: mikhailsal <[email protected]>
Co-authored-by: Ikraam Ghoor <[email protected]>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1v/adversarial-native#1 reader=adversarial-native
Review-Finding: p1v/adversarial-native#2 reader=adversarial-native
Review-Finding: p1v/adversarial-native#3 reader=adversarial-native
Review-Finding: p1v/outside-voice#2 reader=outside-voice
Review-Finding: p1v/outside-voice#3 reader=outside-voice
@capy-ai

capy-ai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Thank you @ikraamg. This landed in #4679, rebuilt on current main with you credited as co-author. A Rails file under app/ or lib/ now selects its RSpec spec at the conventional path (also under an engine's root) when that spec exists. Closing this in favor of #4679.

@capy-ai capy-ai Bot closed this Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant