-
Notifications
You must be signed in to change notification settings - Fork 13
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
Support API_URLs that include path #41
Conversation
Needs somebody from @samandmoore and @effron to claim domain review Use the shovel operator to claim, e.g.:
|
lib/webvalve/fake_service_wrapper.rb
Outdated
end | ||
|
||
def path_prefix | ||
@path_prefix ||= URI::parse(@service_config.service_url).path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we're parsing URLs all over the place and could consolidate onto the config. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, it might be nice to have the config expose a path_prefix
method instead of doing this here. it won't be used anywhere else, but it would be tidy.
@@ -132,7 +132,7 @@ def webmock_service(config) | |||
WebMock.stub_request( | |||
:any, | |||
url_to_regexp(config.service_url) | |||
).to_rack(FakeServiceWrapper.new(config.service_class_name)) | |||
).to_rack(FakeServiceWrapper.new(config)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor API change but it's an internal class right?
25e9fad
to
61fc29a
Compare
@@ -70,6 +70,7 @@ def reset | |||
allowlisted_urls.clear | |||
fake_service_configs.clear | |||
stubbed_urls.clear | |||
WebMock.reset! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was required to prevent global state from mucking up the test run and making this test flake:
https://github.com/Betterment/webvalve/pull/41/files#diff-4f60a691d33035e7b6c85487ba4937efR55
I was surprised that we leave existing WebMock stubs around even when we clear out the local registry of stubbed URLs. But maybe this shouldn't go here? I could put it in that one test's before
hook instead? 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems fine. i think reset is only used internally.
<<domain platform tafn |
@smudge needs to incorporate feedback from @samandmoore. Bump when done. |
55486d1
to
a16f555
Compare
Even though I swear URL paths cannot have newlines ;-)
a16f555
to
9517629
Compare
bump @samandmoore (and @jmileham) I got cute and wrote this test (and it passed) but then I deleted it and changed the it 'is immune to newlines that are injected in the path' do
with_env 'DUMMY_API_URL' => 'http://dummy.dev/gg' do
WebValve.register subject.name
WebValve.setup
expect { Net::HTTP.get(URI('http://dummy.dev/gg/banana/%0Agg/widgets')) }
.to raise_error(RuntimeError, /route not defined for GET/)
expect { Net::HTTP.get(URI("http://dummy.dev/gg/banana/\ngg/widgets")) }
.to raise_error(URI::InvalidURIError, /bad URI\(is not URI\?\)/)
end
end |
Needs @samandmoore to provide platform review When you finish a round of review, be sure to say you've finished or sign off on the PR, e.g.:
If you're too busy to review, unclaim the PR, e.g.:
|
i assume you deleted the test because you finally proved to yourself once and for all that it doesn't make sense to use an operator that means "match the front of the current line," in a construct that doesn't support multiple lines |
just that one last suggestion then domainlgtm platformlgtm i think we can cut this as the official 1.0.0 release :) |
Approved! 👏 🙌 🌮 |
expect(subject.path_prefix).to eq '/welcome' | ||
end | ||
with_env 'DUMMY_API_URL' => 'http://zombo.com/welcome/' do | ||
expect(subject.path_prefix).to eq '/welcome' # Ignores trailing '/' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m sort of testing URI::parse but I wanted a loose demonstration of basic URL/path expectations in case the underlying parsing implementation ever changes.
/domain @samandmoore @effron
/platform @samandmoore @effron
Will annotate below.
Build is currently failing intermittently due to a test order thing. Will debug that but wanted to get the code up in the meantime.