fix: safely extract request/response when let() overrides exist#294
Open
AlexeyMatskevich wants to merge 4 commits intoexoego:masterfrom
Open
fix: safely extract request/response when let() overrides exist#294AlexeyMatskevich wants to merge 4 commits intoexoego:masterfrom
AlexeyMatskevich wants to merge 4 commits intoexoego:masterfrom
Conversation
When users define `let(:request)` or `let(:response)` in their specs, the context methods would return those stubbed values instead of the actual ActionDispatch objects. This caused OpenAPI extraction to fail. The fix prioritizes the integration_session if available, then falls back to checking if the method is defined by RSpec memoization helpers and calls the super_method to get the real request/response objects.
49647c5 to
36336cd
Compare
…verification Replace indirect after(:context) verification with a dedicated /override_probe endpoint and inline RSpec::OpenAPI::RecordBuilder.build call. This makes the test self-contained and easier to understand.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #294 +/- ##
==========================================
+ Coverage 98.91% 98.93% +0.02%
==========================================
Files 20 20
Lines 735 751 +16
Branches 188 195 +7
==========================================
+ Hits 727 743 +16
Misses 8 8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add explicit tests for the request_response extraction logic: - Test that integration_session is used when available - Test fallback to instance variables when integration_session returns nil
|
|
||
| it 'calls regular methods directly', openapi: false do | ||
| context = Object.new | ||
| def context.custom_method; :value; end |
Check notice
Code scanning / Rubocop
Avoid single-line methods. Note test
Add tests for uncovered branches in safe_context_method and integration_session to improve branch coverage from ~66% to 80%. Covers: - respond_to? returning false - method.call for non-RSpec owned methods - integration_session returning nil - NameError rescue path
9d99ca1 to
9bdeda6
Compare
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
let(:request)orlet(:response)in their specsintegration_sessionif available for request/response extractionsuper_methodto get actual objectsTest plan
let(:request)andlet(:response)overridesRelated issue #251