Fix Regexp and Addressable::Template URL handling#105
Draft
jacamera wants to merge 1 commit into
Draft
Conversation
`FakeServiceConfig#service_url` previously stringified every URL via `strip_basic_auth(url.to_s)` before it reached `ServiceUrlConverter`, which meant the converter's non-String passthrough branch was unreachable from `Manager#webmock_service`. As a result, the documented `Regexp` and `Addressable::Template` registration forms produced WebMock stubs that matched nothing, and `path_prefix` either returned garbage or raised `URI::InvalidURIError`. See Betterment#104. - Only apply `strip_basic_auth` to String URLs; pass `Regexp` and `Addressable::Template` through untouched. - Default `path_prefix` to `""` for non-String URLs (no-op against `FakeServiceWrapper`'s leading-prefix gsub) instead of trying to parse a path out of the pattern. - Add an optional `path_prefix:` keyword to `WebValve.register` for callers who want relative fake-service routes when using a `Regexp` or `Addressable::Template` URL. Adds unit coverage for the new URL forms and override, plus the end-to-end integration coverage that was missing — registering a fake with a `Regexp` / `Template` URL, firing a real `Net::HTTP` request, and asserting the fake responds. The previous test suite only checked the arguments handed to `WebMock.stub_request` and never exercised `FakeServiceWrapper#call`, which is why the bug shipped undetected. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
FakeServiceConfig#service_urlpreviously stringified every URL viastrip_basic_auth(url.to_s)before it reachedServiceUrlConverter, which meant the converter's non-String passthrough branch was unreachable fromManager#webmock_service. As a result, the documentedRegexpandAddressable::Templateregistration forms produced WebMock stubs that matched nothing, andpath_prefixeither returned garbage or raisedURI::InvalidURIError. See #104.strip_basic_authto String URLs; passRegexpandAddressable::Templatethrough untouched.path_prefixto""for non-String URLs (no-op againstFakeServiceWrapper's leading-prefix gsub) instead of trying to parse a path out of the pattern.path_prefix:keyword toWebValve.registerfor callers who want relative fake-service routes when using aRegexporAddressable::TemplateURL.Adds unit coverage for the new URL forms and override, plus the end-to-end integration coverage that was missing — registering a fake with a
Regexp/TemplateURL, firing a realNet::HTTPrequest, and asserting the fake responds. The previous test suite only checked the arguments handed toWebMock.stub_requestand never exercisedFakeServiceWrapper#call, which is why the bug shipped undetected.