Skip to content
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

WebMock::Response::InvalidBody #428

Closed
alexfalkowski opened this issue Nov 2, 2014 · 9 comments
Closed

WebMock::Response::InvalidBody #428

alexfalkowski opened this issue Nov 2, 2014 · 9 comments

Comments

@alexfalkowski
Copy link

Upgrading from version 1.20.0 to 1.20.2 I now get:

WebMock::Response::InvalidBody: must be one of: [Proc, IO, Pathname, String, Array]. 'Hash' given. Is this by design?

@bblimke
Copy link
Owner

bblimke commented Nov 3, 2014

@alexfalkowski yes, please see #427

It's ambiguous how the hash should be encoded. JSON, XML, url-encoded?

Could you please share an example that used to work for you? I'm surprised it did before :)

/cc @dapplebeforedawn

@alexfalkowski
Copy link
Author

A simplified version of the code

json = JSON.parse "{}"
stub_request(:post, "www.example.com").with(body:  json)

Looking at the tests I see that it is silly doing it this way, though it works. I might have to rewrite the tests.

@bblimke
Copy link
Owner

bblimke commented Nov 3, 2014

This code only declares request body for the stub, not the response body. It would not be affected by the change in 1.20.2

@alexfalkowski
Copy link
Author

When I am in front of the code I will post up the example (might be getting something wrong).

@alexfalkowski
Copy link
Author

So looking at the code we do the following:

json = JSON.parse "{}"
stub_request(:get, url).to_return(body: json)

@alexfalkowski
Copy link
Author

I will see if I can rewrite the tests :)

@alexfalkowski
Copy link
Author

I have managed to rewrite the tests, due to this change it made mew realise the tests were wrong. Thanks guys :)

@markjlorenz
Copy link

That makes me very happy. What just happened to you is the reason I wrote
the PR to begin with.

@alexfalkowski
Copy link
Author

Thanks mate 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants