feat(core): broaden .understandignore starter — Ruby RSpec/Minitest patterns#597
Merged
Lum1104 merged 4 commits intoJul 21, 2026
Merged
Conversation
Ruby's second-most-common testing tool (arguably first in Rails-adjacent projects — discourse, gitlab, homebrew all use RSpec) organises tests under a top-level `spec/` directory rather than `test/`. The existing list caught Minitest / Rails default `test/` but silently ingested every `spec/**/*.rb` file for RSpec-based projects. Add `spec` as a case-insensitive exact-name match. Kept separate from the Ruby file-pattern group added in follow-up commits so users on Minitest-only projects (rails/rails core, ruby/ruby) aren't affected.
Ruby ecosystems split between two test frameworks with different
file-naming conventions:
RSpec — `*_spec.rb`, canonically under `spec/`
(discourse, homebrew, gitlab, fastlane, rubocop)
Minitest — `*_test.rb` / `test_*.rb`, canonically under `test/`
(rails/rails, activerecord, ruby/ruby)
Both top-level dirs are now caught by EXACT_DIR_NAMES (`spec` was
added in the previous commit), but individual files sometimes leak
elsewhere — engine test files under `app/**/*_test.rb` in Rails
engines, gem repos that colocate small `*_spec.rb` beside
`lib/**/*.rb`. The file globs are what catch that shape.
Tests: assert Ruby sub-header and all three globs; extend the
stable-order invariant to place Ruby after Rust.
Test harness bootstrap files loaded by every test in the suite:
spec_helper.rb — RSpec baseline configuration
test_helper.rb — Minitest baseline configuration
rails_helper.rb — Rails-specific RSpec bootstrap (require rails
env + all initialisers)
These sit under `spec/` or `test/` in canonical layouts (already
caught by dir rules), but Rails engines and multi-app monorepos
sometimes reference them via `require_relative` from other paths.
Kept as separate opt-in globs so projects that share helpers with
production code paths (rare, but legal) can leave them commented.
The initial comment was speculative ("individual files sometimes leak
elsewhere"). Measurement across 10 major Ruby repos showed the picture
is much stronger and closer to C++ than to Rust:
Weighted total reduction across the sample: 51% (−11.80M tokens on
92 MB of Ruby source), the highest of any language group so far.
spec/ dir rule alone drives 46 pp; file globs add the remaining 5 pp
by catching *_spec.rb in gem lib/ trees, Minitest files leaking
outside test/ in Rails engines, and helper bootstraps referenced
via require_relative.
Hero projects:
rubocop/rubocop 67% (−1.75M tok) highest percent
discourse/discourse 60% (−5.53M tok) highest absolute
ruby/ruby 59% (−3.66M tok)
rspec/rspec-rails 61% (−0.07M tok)
fastlane/fastlane 42% (−0.73M tok)
Update the block comment so a future reader lands on the right mental
model — Ruby is a big win precisely because the ecosystem clusters
tests but under a directory (`spec/`) that the starter had previously
missed entirely.
This was referenced Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EXACT_DIR_NAMES+=spec— RSpec's canonical home directory (used by discourse, homebrew, gitlab, fastlane, rubocop, and everyrspec-railsscaffold). This is the load-bearing addition:spec/alone drives 46 pp of the 51% weighted total reduction below.TEST_PATTERN_GROUPSentryRubywith 6 patterns (RSpec*_spec.rb, Minitest*_test.rb/test_*.rb, harness bootstrapsspec_helper.rb/test_helper.rb/rails_helper.rb).ignore-generator.test.ts; ordering invariant extended to place Ruby after Rust.scala-extractor.test.ts/swift-extractor.test.tsreproduce unmodified onorigin/main).SKILL.mdunchanged — Phase 0.5 delegates togenerate-ignore.mjssince a0155c5, so no inline duplicate to keep in sync.Why these patterns (and not others)
Ruby is closer to C++ in ecosystem shape than to Rust: aggressive test clustering under known dirs, plus a few naming conventions the starter had never been taught about. The
spec/gap was the load-bearing miss — with it added, every RSpec-based project (which is most modern Rails-adjacent Ruby) sees the discourse-scale reduction the moment it opts in.Rejected as too project-specific or ambiguous:
**/*_shared_examples.rb(RSpec-only, files usually live underspec/support/which is already caught byspec/),**/factories.rb(FactoryBot — underspec/factories/, same),**/schema.rb(Rails-generated, but path isdb/schema.rb— surfaces via.gitignoreextraction rather than a starter suggestion).Kept
spec_helper.rb/test_helper.rb/rails_helper.rbas separate opt-in globs because engines and multi-app monorepos occasionally reference them viarequire_relativefrom outside the canonical spec/test trees.Token impact (measured across 10 public Ruby repos)
Methodology:
gh api .../git/trees?recursive=1, Ruby source =.rb .rake .gemspec, 1 MiB ≈ 262K tokens. Two hero projects reported below — the highest percentage win and the highest absolute win — same pattern as PR #582.rubocop/rubocopdiscourse/discourserubocop— highest %. RSpec-dominant repo wherespec/was the bulk of the untouched source tree.discourse— highest absolute saving. 3798 files underspec/— the single largest un-caught test tree in the survey.Weighted total across all 10 repos: −11.80M tok / 51% on 92 MB of Ruby source — the highest of any language group added so far. Full breakdown (for context, not repeated in the hero table):
ruby/ruby59% / −3.66M,rspec/rspec-rails61%,fastlane/fastlane42%,rails/rails2% (already covered by existingtest/dir rule),Homebrew/brew1%,jekyll/jekyll0%,shopify/liquid3%,basecamp/kamal0%.The
spec/dir rule alone accounts for 46 pp of the 51% weighted total; the file globs add another 5 pp by catching*_spec.rbin gemlib/trees, Minitest files that leak outsidetest/in Rails engines, and the helper bootstraps.Test plan
pnpm --filter @understand-anything/core build— cleanpnpm --filter @understand-anything/core exec vitest run src/__tests__/ignore-generator.test.ts— 48/48 pass (3 new Ruby tests + thespec/dir test)pnpm --filter @understand-anything/core test— 898 pass, 2 pre-existing wasm-module failures also present onorigin/main(unrelated: scala-extractor, swift-extractor)pnpm lint— clean.understandignoreon a fixture withspec/,test/, plus alib/foo.rb+lib/foo_spec.rb— Ruby group emitted after Rust, all six patterns present,# spec/in the detected-dirs section, all commentedCloses #596