Convert the request body correctly when it is a String #238

Merged
merged 1 commit into from Sep 25, 2016

Projects

None yet

2 participants

@jnormington
Contributor

so hashie coercion doesnt error when it retrieves and the requests have body content.

As currently if it retrieves a request with body content it errors out with the following;

Cannot coerce property :body from String to MockServer::Model::Body: undefined method `each_pair' for "Hello this is a message":String

It appears that the mockserver java core doesn't return the type of body and this appears to be implied by this java spec - https://github.com/jamesdbloom/mockserver/blob/master/mockserver-core/src/test/java/org/mockserver/model/HttpRequestTest.java#L96-L114

My gut feeling tells me it ideally should returned from the overridden toString methods in all the classes extending Body like StringBody class below

https://github.com/jamesdbloom/mockserver/blob/master/mockserver-core/src/main/java/org/mockserver/model/StringBody.java#L65-L68
@jnormington jnormington Convert the request body correctly when it is a String
so hashie coercion doesnt error when it retrieves and the
requests have body content
a3a3e63
@jnormington
Contributor

@jamesdbloom on second thoughts this doesn't seem write if a request body is of type binary then this would break that (not that it is working currently) - so I guess the mockserver request response should also include the bodyType ?

@jamesbloomnektan jamesbloomnektan merged commit bcccbbc into jamesdbloom:master Sep 25, 2016
@jamesbloomnektan
Collaborator

When the body is a binary it should include the bodyType, only bodies which are strings support the shorthand of no bodyType.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment