Summary
Incremental cleanup of the RSpec suite: reduce class pollution, extract shared helpers, and chip away at .rubocop_todo.yml exclusions — without rewriting the intentional inline-DSL spec style.
Problem
The spec suite documents DSL behavior well, but accumulates maintenance cost:
| Issue |
Examples |
Impact |
Constants defined inside describe blocks |
spec/comma/comma_spec.rb, AR/Mongoid specs |
RuboCop Lint/ConstantDefinitionInBlock excluded |
Repeated class Foo names across examples |
Multiple files |
Order-dependent pollution if examples leak |
| Long inline expected CSV strings |
comma_spec.rb, users_controller_spec.rb |
Hard to read diffs |
| Stale RuboCop todo entries |
.rubocop_todo.yml |
Masks fixable offenses in touched files |
The project intentionally uses inline classes to show DSL usage — this issue is about hygiene, not replacing that pattern entirely.
Proposed approach (incremental)
1. Shared helper for anonymous comma classes
# spec/support/comma_class_helper.rb
def define_comma_class(&block)
Class.new do
class_eval(&block)
end
end
Use in new/changed specs; migrate old ones opportunistically.
2. CSV expectation helper
def expect_csv(output, headers:, rows:)
expected = CSV.generate { |csv| csv << headers; rows.each { |r| csv << r } }
expect(output).to eq(expected)
end
Reduces copy-paste in comma_spec and controller specs.
3. Shared fixture models (optional)
Move stable models like Book / Isbn patterns to spec/support/models/ only where duplication exceeds benefit — keep Book in spec/non_rails_app/ruby_classes.rb as the canonical example.
4. RuboCop todo reduction
When touching a spec file, fix or narrow exclusions instead of adding new ones.
Files likely involved
spec/support/ (new helpers)
spec/comma/comma_spec.rb
spec/comma/data_extractor_spec.rb
spec/comma/header_extractor_spec.rb
spec/controllers/users_controller_spec.rb
.rubocop_todo.yml
Acceptance criteria
Labels (suggested)
refactor, tests, good first issue
Depends on
None. Best done alongside other refactor PRs (touch spec once).
Out of scope
- Full spec rewrite
- Changing Appraisal matrix or CI structure
Summary
Incremental cleanup of the RSpec suite: reduce class pollution, extract shared helpers, and chip away at
.rubocop_todo.ymlexclusions — without rewriting the intentional inline-DSL spec style.Problem
The spec suite documents DSL behavior well, but accumulates maintenance cost:
describeblocksspec/comma/comma_spec.rb, AR/Mongoid specsLint/ConstantDefinitionInBlockexcludedclass Foonames across examplescomma_spec.rb,users_controller_spec.rb.rubocop_todo.ymlThe project intentionally uses inline classes to show DSL usage — this issue is about hygiene, not replacing that pattern entirely.
Proposed approach (incremental)
1. Shared helper for anonymous comma classes
Use in new/changed specs; migrate old ones opportunistically.
2. CSV expectation helper
Reduces copy-paste in comma_spec and controller specs.
3. Shared fixture models (optional)
Move stable models like
Book/Isbnpatterns tospec/support/models/only where duplication exceeds benefit — keepBookinspec/non_rails_app/ruby_classes.rbas the canonical example.4. RuboCop todo reduction
When touching a spec file, fix or narrow exclusions instead of adding new ones.
Files likely involved
spec/support/(new helpers)spec/comma/comma_spec.rbspec/comma/data_extractor_spec.rbspec/comma/header_extractor_spec.rbspec/controllers/users_controller_spec.rb.rubocop_todo.ymlAcceptance criteria
spec/support/comma_class_helper.rb.rubocop_todo.ymlOR file an explicit follow-up list of remaining exclusionsLabels (suggested)
refactor,tests,good first issueDepends on
None. Best done alongside other refactor PRs (touch spec once).
Out of scope