Skip to content

refactor: prefer described_class in specs#2725

Merged
olleolleolle merged 1 commit into
masterfrom
refactor/use-described-class-all-specs
Jul 27, 2026
Merged

refactor: prefer described_class in specs#2725
olleolleolle merged 1 commit into
masterfrom
refactor/use-described-class-all-specs

Conversation

@mroderick

@mroderick mroderick commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

This PR is adopting @olleolleolle's suggestion in #2551 (review), to use described_class for better ergonomics.

This is part of a solution for #2554.


Use described_class instead of repeating class names in specs.

What changed:

  • Rebased onto master, which now enforces RuboCop across the whole codebase via .rubocop_todo.yml (PR chore: enforce RuboCop across the codebase with a todo file #2726). The temporary spec/.rubocop.yml from an earlier version of this branch was removed because it is no longer needed.
  • Ran bundle exec rubocop -A --only RSpec/DescribedClass spec/, which corrected 135 offenses across 36 files.
  • Fixed a Layout/FirstHashElementIndentation offense introduced by the autocorrect in spec/models/invitation_log_entry_spec.rb.
  • Regenerated .rubocop_todo.yml to reflect the reduced offense count.
  • Ran the affected specs: 423 examples, 0 failures.

This makes renaming a class under test less cumbersome because the specs no longer hard-code the class name in subject, let, mailer calls, class methods, etc.

@mroderick
mroderick requested a review from olleolleolle July 27, 2026 09:13
@mroderick
mroderick marked this pull request as ready for review July 27, 2026 09:14
@mroderick
mroderick enabled auto-merge July 27, 2026 14:46
@mroderick
mroderick disabled auto-merge July 27, 2026 14:46
@mroderick
mroderick force-pushed the refactor/use-described-class-all-specs branch from ca4321f to 2d715a3 Compare July 27, 2026 15:01
@olleolleolle
olleolleolle merged commit 19df7a2 into master Jul 27, 2026
9 checks passed
@olleolleolle
olleolleolle deleted the refactor/use-described-class-all-specs branch July 27, 2026 15:05
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