We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
headers = { 'Accept'=>'application/json', 'Accept-Encoding'=>'gzip, deflate', 'Authorization'=>'Bearer loremipsum', 'Content-Length'=>'61', 'Content-Type'=>'application/json', 'Host'=>'my_url', 'User-Agent'=>'rest-client/2.0.2 (darwin17.6.0 x86_64) ruby/2.3.8p459' }
::WebMock.stub_request(:post, url). with(:body => ::WebMock.hash_including(params.to_json),:headers => headers). to_return(status: 200, body: "", headers: {})
stub_request(:post, "my_url"). with(:body => "{\"name\":\"soraya-jast\",\"is_platform_access_only\":true}", :headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip, deflate', 'Authorization'=>'Bearer loremipsum', 'Content-Length'=>'53', 'Content-Type'=>'application/json', 'Host'=> 'my_host', 'User-Agent'=>'rest-client/2.0.2 (darwin17.6.0 x86_64) ruby/2.3.8p459'}). to_return(:status => 200, :body => "", :headers => {}) registered request stubs: stub_request(:post, "my_url"). with(:body => hash_including({"{\"is_platform_access_only\":true}"=>#<WebMock::Matchers::AnyArgMatcher:0x00007fea71adbb38>}), :headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip, deflate', 'Authorization'=>'Bearer loremipsum', 'Content-Length'=>'61', 'Content-Type'=>'application/json', 'Host'=>'my_host', 'User-Agent'=>'rest-client/2.0.2 (darwin17.6.0 x86_64) ruby/2.3.8p459'})``` Where am I doing wrong?
The text was updated successfully, but these errors were encountered:
You should be passing a hash to hash_including, not json, i.e. hash_including(params). Webmock takes care of parsing request body according to the content type when you use that sort of matcher (see https://github.com/bblimke/webmock/blob/master/lib/webmock/request_pattern.rb#L272 )
hash_including
hash_including(params)
Sorry, something went wrong.
I think this can be closed.
No branches or pull requests
headers = {
'Accept'=>'application/json',
'Accept-Encoding'=>'gzip, deflate',
'Authorization'=>'Bearer loremipsum',
'Content-Length'=>'61',
'Content-Type'=>'application/json',
'Host'=>'my_url',
'User-Agent'=>'rest-client/2.0.2 (darwin17.6.0 x86_64) ruby/2.3.8p459'
}
::WebMock.stub_request(:post, url).
with(:body => ::WebMock.hash_including(params.to_json),:headers => headers).
to_return(status: 200, body: "", headers: {})
The text was updated successfully, but these errors were encountered: