-
Notifications
You must be signed in to change notification settings - Fork 964
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
Httparty 0.15.0 not working properly with WebMock? #547
Comments
Hmmm. Nothing I can think of immediately. Any chance you could provide a small script or failing test PR to demonstrate the failure that was reproducible? That would really help for fixing it. |
@jnunemaker Luckily, the project I am working with is Open Source! I have a branch where my specs are failing due to above issue. Take a look at https://github.com/ehannes/fortnox-api/tree/httparty-issue. If that is too much to ask for, or if you have any questions, please contact me :) |
Any chance someone with knowledge of httparty can have a look at this? :) |
I think #518 + how you are setting headers in fortnox is what affected you. If you add I usually recommend not using the class methods from an instance (ala module Fortnox
module API
class Base
include HTTParty
headers({
'Content-Type' => 'application/json',
'Accept' => 'application/json',
})
def initialize(headers = {})
@base_uri = get_base_url
@headers = headers.merge({
'Client-Secret' => get_client_secret,
})
check_access_tokens!
end
def get(path, options = {}, &block)
provided_headers = options[:headers] || {}
options[:headers] = @headers.merge(provided_headers)
options[:base_uri] ||= @base_uri
self.class.get(path, options, &block)
end
# def post, etc
end
end
end Using the class methods from the instance makes things not thread safe and pollutes the class. |
Oh, and let me know if you have any more questions about it. Here is the spec passing on that branch with 0.15.6:
|
I am developing a gem that uses Httparty. I have stubbed a request in one of my tests with WebMock. The test passes with httparty version
0.14.0
and breaks in0.15.0
. Removing the request stubbing reveals the request. Have a look at the examples below.With httparty
0.14.0
:With httparty
0.15.0
:As you can see the headers are totally different (and totally wrong) with
0.15.0
. Is this a breaking change in0.15.0
. What can I do to fix it?The text was updated successfully, but these errors were encountered: