Repository navigation
Validate each test request against its own operation - #47
Merged
Merged
Conversation
Owner
|
@ralder Thanks! |
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.
Problem
Committee::Rails::Test::Methods#request_objectmemoizesCommittee::Rails::RequestObject.new(integration_session.request)in an ivar for the whole test example:The core committee gem already fixed the same mine in interagent/committee#485 (committee 5.6.4):
schema_validatoris now rebuilt fromrequest_objecton eachassert_schema_conform, precisely so every request is validated against its own operation. But committee-rails pinsrequest_objectitself to the first request of the example, so the core fix only half-works here.Symptom: in an example with 2+ HTTP requests, the second
assert_schema_conformvalidates the request/response against the first request's operation, producing a misleadingCommittee::InvalidResponse("response definition does not exist" / "expected object, but received Array"). Workaround in apps: manually resetting@request_object = nilbetween requests.Fix
Mirror the core change: drop the
||=sorequest_objectis rebuilt from the currentintegration_session.requeston every call:@default_schemamemoization is intentionally untouched — the schema does not change between requests.Compatibility
For single-request examples behavior is identical; only multi-request examples change (they now validate correctly). Added a spec covering the scenario:
POST /users+ assert, thenGET /users+ assert in one example (fails onmain, passes with this change).🤖 Generated with Claude Code