refactor(tests): clean up notes_spec shared examples after #6927#6939
Merged
refactor(tests): clean up notes_spec shared examples after #6927#6939
Conversation
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>
Contributor
There was a problem hiding this comment.
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
organizationfixture to the outer example group and switches shared example declarations fromRSpec.shared_examplesto locally scopedshared_examples. - Adds inline comments documenting the required
usercontract for each shared example. - Cleans up wording and formatting in spec descriptions and
expectblocks for consistency.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up cleanup to PR #6927, addressing review feedback:
RSpec.prefix onRSpec.shared_examplesso the generic names"create"/"edit"/"update"/"delete"aren't registered globally and won't collide with shared examples in other spec files.usercontract. Each shared example block now opens with# Caller must define: let(:user)so future contributors know what to provide alongsideit_behaves_like."is successful if note belongs for volunteer"→"... belongs to volunteer"(the original wording).expectstyle. The two volunteer-only inlined tests still usedexpect { ... }.not_to change(...)curly-block style; the rest of the file usesexpect do ... end.not_to change(...). Made them consistent.let(:organization). It was redeclared in all four shared example blocks; now defined once on the outerRSpec.describeand inherited. The two inlined volunteer tests that did their ownorganization = create(:casa_org)now use the let too.describeblocks 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.it_behaves_likeshould produce contexts under each role; descriptions should read naturally.🤖 Generated with Claude Code