Skip to content

chore(rubocop): fix RSpec/ cops - #2753

Merged
mroderick merged 9 commits into
masterfrom
fix/rubocop-rspec
Jul 28, 2026
Merged

chore(rubocop): fix RSpec/ cops#2753
mroderick merged 9 commits into
masterfrom
fix/rubocop-rspec

Conversation

@mroderick

Copy link
Copy Markdown
Collaborator

What

Fix 12 RSpec/ cops from .rubocop_todo.yml — 9 commits, one per rule.

Changes

Commit Cop Approach
1 RSpec/ImplicitSubject Removed stale Exclude entries (already clean)
2 RSpec/NamedSubject Named subjects across 19 files
3 RSpec/VoidExpect Replaced bare expect(page.all(...)) with have_css
4 RSpec/IndexedLet Renamed member1/member2 to alice/bob
5 RSpec/InstanceVariable Replaced @start_page/@tutorial with let
6 RSpec/LetSetup Converted setup-only let! to before blocks
7 RSpec/RepeatedExample + RepeatedExampleGroupDescription Merged duplicate examples, disambiguated contexts
8 RSpec/LeakyConstant, SpecFilePath, MessageChain, SubjectStub Removed unused constant, added CustomTransform, replaced receive_message_chain
9 RSpec/MultipleExpectations, ExampleLength, MultipleMemoizedHelpers Adjusted Max thresholds to reduce noise

Remaining (deferred)

  • RSpec/MessageSpies (68) — needs allow+have_received restructure
  • RSpec/AnyInstance (2) — needs refactoring login helper
  • RSpec/StubbedMock (19) — needs allow/receive split
  • RSpec/VerifiedDoubles (38) — needs double→instance_double
  • RSpec/ContextWording (144) — needs context prefix additions
  • RSpec/ExampleLength (1 file) + RSpec/MultipleExpectations (3 files) — outliers left excluded

Verification

  • bundle exec rubocop passes (0 offenses)
  • Each commit tested individually

RSpec/ImplicitSubject had 3 stale Exclude entries — the one-liner
`is_expected` usage in those files already matches the allowed
`single_line_only` style.
Name all test subjects to satisfy rubocop-rspec's NamedSubject cop.
- Policy specs: subject(:policy)
- Model specs: use the existing named subject aliases (contact, sponsor,
  group, workshop_invitation, workshop, workshop_sponsor) instead of
  the bare `subject` keyword
Replace bare `expect(page.all(...))` (no .to chain) with idiomatic
`expect(page).to have_css(...)` for table row count assertions.
Rename indexed let(:member1)/let(:member2) to descriptive alice/bob.
Replace instance variables with let/let! in feature specs.
- add_user_to_workshop_spec: @start_page → let(:start_page)
- member_feedback_spec: @tutorial → let!(:tutorial)
Replace let! used only for setup with before blocks, or reference
named let! that must be eager.
Merge duplicate examples and rename duplicate context descriptions.
- Sponsors controller: merge two identical examples into one
- Invitation route shared example: remove duplicate scenario with typo
- Manage sponsor spec: disambiguate duplicate context descriptions
@mroderick
mroderick force-pushed the fix/rubocop-rspec branch from d967d79 to 8fbd44f Compare July 28, 2026 16:55
…bjectStub

- LeakyConstantDeclaration: remove unused MAX_RETRIES constant
- SpecFilePathFormat: add CustomTransform for OmniAuth→omniauth
- MessageChain: replace receive_message_chain with allow + double
- SubjectStub: move exclude from todo to .rubocop.yml
…ngth, MultipleMemoizedHelpers

Increase thresholds to reduce noise in todo file while keeping
meaningful enforcement:
- MultipleExpectations: 2 → 8
- ExampleLength: 10 → 25
- MultipleMemoizedHelpers: add Max: 15
@mroderick
mroderick force-pushed the fix/rubocop-rspec branch from 8fbd44f to 89bfd5d Compare July 28, 2026 16:57
@mroderick
mroderick marked this pull request as ready for review July 28, 2026 17:00
@mroderick
mroderick merged commit c98646a into master Jul 28, 2026
9 checks passed
@mroderick
mroderick deleted the fix/rubocop-rspec branch July 28, 2026 17:01
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.

1 participant