Skip to content

Extract ORM spec models out of describe blocks (issue #169) - #182

Merged
eitoball merged 6 commits into
masterfrom
eitoball/incremental-spec-suite-hygiene-2
Sep 28, 2026
Merged

eitoball merged 6 commits into
masterfrom
eitoball/incremental-spec-suite-hygiene-2

Conversation

@eitoball

Copy link
Copy Markdown
Contributor

What

Continues issue #169 (spec suite hygiene): moves the ActiveRecord/Mongoid/DataMapper model classes previously defined inside RSpec describe blocks into spec/support/models/, and reduces .rubocop_todo.yml accordingly.

Why

spec/comma/rails/active_record_spec.rb, mongoid_spec.rb, and data_mapper_collection_spec.rb each defined their ORM model classes inline inside a describe block, which required a blanket Lint/ConstantDefinitionInBlock exclusion (17 offenses) in .rubocop_todo.yml. Issue #169's acceptance criteria call for reducing at least one such exclusion without changing spec behavior. Since these classes must stay real named constants (ActiveRecord relies on the class name for table/STI inference), the fix is to move them out of the block rather than anonymize them.

Changes

  • Extracted model classes into new files, each still guarded by the same if defined?(...) check the spec file already used, and auto-loaded via the existing spec/support/**/*.rb glob in spec_helper.rb:
    • spec/support/models/active_record_models.rb (Picture, Person, Job, PersonFormatter, Animal, Dog, Cat)
    • spec/support/models/mongoid_models.rb (Person)
    • spec/support/models/data_mapper_models.rb (Person, DataMapper.finalize)
  • Trimmed the corresponding describe blocks in the 3 spec files down to before/it blocks only — no example behavior changed.
  • .rubocop_todo.yml: removed the Lint/ConstantDefinitionInBlock exclusion entirely (0 offenses now); moved the Style/StringConcatenation exclusion from active_record_spec.rb to active_record_models.rb (the offending 'Dog-' + name lines moved with the code, not a new offense).
  • spec/spec_helper.rb: added SimpleCov add_filter entries for the new mongoid_models.rb/data_mapper_models.rb, mirroring the existing filters for their spec files — both are guarded by ORM gems this repo never installs (no mongoid/data_mapper in any Gemfile/gemfiles/*/Appraisals), so without the filter their always-false-guard lines would count as uncovered and dilute the coverage metric.
  • Added docs/superpowers/plans/2026-09-27-issue-169-orm-model-extraction.md documenting the implementation plan.

Verified locally: bundle exec rubocop clean (41 files), bundle exec rspec 57/57, and BUNDLE_GEMFILE=gemfiles/active8.1.3.1.gemfile bundle exec rspec 68/68 (including the 11-example active_record_spec.rb matching its pre-change baseline).

Note: mongoid_spec.rb/data_mapper_collection_spec.rb (and their new model files) never actually execute in this repo's CI today — no gemfile installs those gems. That's a pre-existing condition, unchanged by this PR; flagging as a possible follow-up.

🤖 Generated with Claude Code

eitoball and others added 6 commits September 27, 2026 16:26
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
spec/support/models/{mongoid,data_mapper}_models.rb are guarded by
if defined?(...) checks that are always false in this repo (no mongoid
or data_mapper gem in any Gemfile), same as the spec files they were
extracted from. Filter them the same way so relocating the guarded
class bodies doesn't dilute measured coverage.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 27, 2026 07:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

Review found only a minor documentation line-reference nit, with no approval-blocking issues.

Review effort: Lite
Findings: None

What changed in this PR

Extracts ORM test models from RSpec blocks into auto-loaded support files while preserving behavior and removing the related RuboCop exclusion.

Changes:

  • Extracted ActiveRecord, Mongoid, and DataMapper models.
  • Updated specs, coverage filters, and RuboCop configuration.
  • Added implementation-plan documentation.
File Summary
spec/​support/​models/​mongoid_models.rb Extracted Mongoid fixture model.
spec/​support/​models/​data_mapper_models.rb Extracted DataMapper fixture models.
spec/​support/​models/​active_record_models.rb Extracted ActiveRecord fixture models.
spec/​spec_helper.rb Added coverage filters for optional ORM models.
spec/​comma/​rails/​mongoid_spec.rb Removed inline Mongoid model definition.
spec/​comma/​rails/​data_mapper_collection_spec.rb Removed inline DataMapper model definition.
spec/​comma/​rails/​active_record_spec.rb Removed inline ActiveRecord model definitions.
docs/​superpowers/​plans/​2026-09-27-issue-169-orm-model-extraction.md Documents the refactor plan.
.rubocop_todo.yml Removed the obsolete exclusion and relocated the string-concatenation exclusion.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants