-
Notifications
You must be signed in to change notification settings - Fork 169
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 scope breaking change of request/response interception. (#241) #242
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,18 @@ def self.proxy | |
def self.certificate_authority | ||
@certificate_authority ||= Billy::Authority.new | ||
end | ||
|
||
# This global shortcut can be used inside of request stubs. You can modify | ||
# the request beforehand and/or modify the actual response which is passed | ||
# back by this method. But you can also implement a custom proxy passing | ||
# method if you like to. This is just a shortcut. | ||
def self.pass_request(params, headers, body, url, method) | ||
handler = proxy.request_handler.handlers[:proxy] | ||
response = handler.handle_request(method, url, headers, body) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nab: It's interesting to see the difference between internet/external APIs here. i.e. the method args are: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes because of: proxy.stub('http://example.com/').and_return(Proc.new { |*args|
response = pass_request(*args)
end There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes it easier to use here without introduce a breaking change (on the order of |
||
{ | ||
code: response[:status], | ||
body: response[:content], | ||
headers: response[:headers] | ||
} | ||
end | ||
end |
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.
Just to confirm, is
params
a dead variable here?