Closed mefellows closed 3 years ago
This is tricky. What are you expecting the HTTP request to look like? null
or false
? How would you differentiate it from an empty body?
This is tricky.
Indeed!
In this case, the body is a literal false
. I think it could be differentiated because it would have the header Content-Length: 5
. At least, that is the only way i can think of separating them.
Any updates here? This issue makes it impossible to write pact tests for endpoints returning only a boolean.
I've changed it to return '' if body.nil?
and released the mock service. I have not done any testing on it. You'll need to get the pact client of whichever language you're using updated to the latest pact-ruby-standalone.
Thanks Beth.
@NiklasEi what language are you using that needs it?
Thanks for the update!
@NiklasEi what language are you using that needs it?
Javascript
Yep, will get a new release out this week. Thanks
Setting the response body directly to a
null
orfalse
value results in an empty response from the mock server.How to reproduce:
I believe the
render_body
method is to blame, specifically this line which checks for a falsey value of the body, meaning if the body isnil
orfalse
it returns an empty string.I couldn't glean from the tests the exact behaviour as to why this statement existed in the first place, but my suspicion is that we need to be able to deal with the 'body not present' case to avoid returning
null
. However, this is presenting the explicitnull
/false
case.FWIW removing that line didn't cause in test failures, so perhaps we need to get some coverage on it.
See https://github.com/pact-foundation/pact-js/issues/257 for background.