Skip to content

feat(core): broaden .understandignore starter — Ruby RSpec/Minitest patterns #596

Description

@thejesh23

Problem

.understandignore starter has no Ruby-specific suggestions. Two gaps in the existing rules:

  1. spec/ is missing from EXACT_DIR_NAMES. The list catches Minitest's test/ but not RSpec's canonical spec/ — used by discourse, homebrew, gitlab, fastlane, rubocop, and every gem generated by rspec-rails. Every spec/**/*.rb file leaks into /understand for those projects.
  2. No file patterns for Ruby test conventions. *_spec.rb (RSpec) and *_test.rb / test_*.rb (Minitest) sometimes leak outside their canonical dirs — gem repos putting small *_spec.rb beside lib/**/*.rb, Rails engines with app/**/*_test.rb.

Proposal

  • Directory: add spec to EXACT_DIR_NAMES (case-insensitive).
  • New Ruby group under TEST_PATTERN_GROUPS:
    • **/*_spec.rb — RSpec
    • **/*_test.rb — Minitest (Rails default)
    • **/test_*.rb — alt Minitest style
    • **/spec_helper.rb — RSpec bootstrap
    • **/test_helper.rb — Minitest bootstrap
    • **/rails_helper.rb — Rails RSpec bootstrap

All commented-out, opt-in. Same model as #76 / #479 / #578 / #581.

Token impact (measured across 10 public Ruby repos)

Methodology: gh api .../git/trees?recursive=1, Ruby source = .rb .rake .gemspec, 1 MiB ≈ 262K tokens.

Project Before (analyzed) After (analyzed) Reduction
rubocop/rubocop 10.38 MB / ~2.59M tok 3.38 MB / ~0.84M tok −1.75M (67%)
discourse/discourse 36.84 MB / ~9.21M tok 14.71 MB / ~3.67M tok −5.53M (60%)
  • rubocop — highest %, RSpec-dominant with spec/ housing the bulk of the source tree.
  • discourse — highest absolute saving. 3798 files under spec/ currently un-caught by the starter.

Weighted total across all 10 repos: −11.80M tok / 51% on 92 MB of Ruby source. 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.

Why Ruby, why these patterns

Ruby is closer to C++ in ecosystem shape than to Rust: aggressive test clustering under known dirs, plus a few 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: **/*_shared_examples.rb (RSpec-only, and files usually live in spec/support/), **/factories.rb (FactoryBot — under spec/factories/ already caught), **/schema.rb (generated by Rails but path is db/schema.rb — surfaces via .gitignore extraction).

Out of scope

  • New EXACT_DIR_NAMES for framework-specific dirs (spec/support/, spec/factories/ — all already caught by spec/ once added).
  • Swift / PHP / Dart groups — follow-ups tracked separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions