-
Notifications
You must be signed in to change notification settings - Fork 561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Support Addressable::URI in request patterns #1073
base: master
Are you sure you want to change the base?
Conversation
As of 3.24.0 release it became impossible to pass Addressable::URI as pattern, while Addressable::Template is still supported. This patch brings back previous behaviour of Addressable::URI. Regression: f651c25
Hey @ixti, Thank you for the PR. If passing Addressable::URI as a request pattern worked, it was only accidental, as this was never officially supported. The change introduced in f651c25 was added as a safety check to ensure WebMock doesn't accept any unsupported argument types. Addressable::Template is supported because it offers functionality for URI templates as per RFC 6570, which can't be expressed by any native Ruby type or string. Since WebMock depends on Addressable::URI, I can consider supporting Addressable::URI for request patterns in the future. However, it would be helpful if you could explain why adding support for this is worthwhile and why existing types are not sufficient. |
LOL. Good to know. :D
When I saw that Addressable::Template was supported, I've assumed removal of Addressable::URI is a regression.
Just upgraded webmock and got a bunch of specs failing as we're using Addressable::URI in specs: module Example
class Application
ADMIN_ORIGIN = Addressable::URI.parse(ENV.fetch("ADMIN_ORIGIN"))
end
end
it "works like a charm" do
stub_request(:get, ADMIN_ORIGIN.join("/some/path")).to_return(status: 200)
...
end But as Addressable::URI was not meant to be supported, I can simply change my specs to call |
After giving it another thought, if that's expected behaviour (no accepting Addressable::URI for any reason in fact), then I'm cool with that. Simply thought it was a regression, as gem depends on Addressable. :D Closing the PR, as it's not a problem (adding PS: On the other hand, if Addressable::Template is supported, it seems like supporting Addressable::URI is pretty OK-ish (at least in my head). |
@ixti Thank you. Supporting Addressable::URI is ok. My main consideration was avoiding unnecessary feature additions that would increase maintenance overhead. If there's significant user demand for Addressable::URI support, I'm happy to merge this PR and maintain the feature. To be honest, it's not a huge overhead to maintain it, but still I prefer to avoid accumulating features that are not necessary. Support Addressable::Template on the other hand was essential, as there is no alternative for defining URI templates. |
If |
@postmodern @bblimke WDYT about:
That way it will support See: 449c0a3 |
Support any #to_str object (including Addressable::URI)
As of 3.24.0 release it became impossible to pass Addressable::URI as pattern, while Addressable::Template is still supported. This patch brings back previous behaviour of Addressable::URI.
Regression: f651c25