Skip to content

refactor(tests): clean up notes_spec shared examples after #6927#6939

Merged
compwron merged 1 commit intomainfrom
more-spec/requests/notes_spec.rb
May 5, 2026
Merged

refactor(tests): clean up notes_spec shared examples after #6927#6939
compwron merged 1 commit intomainfrom
more-spec/requests/notes_spec.rb

Conversation

@compwron
Copy link
Copy Markdown
Collaborator

@compwron compwron commented May 5, 2026

Summary

Follow-up cleanup to PR #6927, addressing review feedback:

  • Scope shared_examples locally. Drop the RSpec. prefix on RSpec.shared_examples so the generic names "create"/"edit"/"update"/"delete" aren't registered globally and won't collide with shared examples in other spec files.
  • Document the implicit user contract. Each shared example block now opens with # Caller must define: let(:user) so future contributors know what to provide alongside it_behaves_like.
  • Fix typo regression. "is successful if note belongs for volunteer""... belongs to volunteer" (the original wording).
  • Normalize expect style. The two volunteer-only inlined tests still used expect { ... }.not_to change(...) curly-block style; the rest of the file uses expect do ... end.not_to change(...). Made them consistent.
  • Hoist let(:organization). It was redeclared in all four shared example blocks; now defined once on the outer RSpec.describe and inherited. The two inlined volunteer tests that did their own organization = create(:casa_org) now use the let too.
  • Normalize context names. The four describe blocks had a mix of "as admin" / "as a supervisor" / "as an admin". All now read "when logged in as an admin" / "as a supervisor" / "as a volunteer".

Net diff: +19 / −24, no behavioral changes.

Test plan

  • bundle exec rspec spec/requests/notes_spec.rb — all 14 examples should pass.
  • Spot-check the rspec output: each it_behaves_like should produce contexts under each role; descriptions should read naturally.

🤖 Generated with Claude Code

Follow-up to the shared-examples extraction. Scope shared_examples to
this describe block (drop the RSpec. prefix that registered them
globally and made the generic names "create"/"edit"/"update"/"delete"
collide-prone), document the implicit let(:user) contract callers must
satisfy, fix the "belongs for volunteer" typo regression, normalize
expect { } to expect do…end for consistency with the new code, hoist
the repeated let(:organization), and standardize context names to use
articles ("as an admin"/"as a supervisor"/"as a volunteer").

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added 🧪 Tests Tests ruby Touches Ruby code labels May 5, 2026
@compwron compwron requested a review from Copilot May 5, 2026 16:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR is a test-only cleanup follow-up to #6927 that refactors spec/requests/notes_spec.rb for clearer shared-example scoping and more consistent spec structure, without changing application behavior.

Changes:

  • Hoists the shared organization fixture to the outer example group and switches shared example declarations from RSpec.shared_examples to locally scoped shared_examples.
  • Adds inline comments documenting the required user contract for each shared example.
  • Cleans up wording and formatting in spec descriptions and expect blocks for consistency.

@compwron compwron merged commit 55c9312 into main May 5, 2026
16 checks passed
@compwron compwron deleted the more-spec/requests/notes_spec.rb branch May 5, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ruby Touches Ruby code 🧪 Tests Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants