sideshowcoder / canned

Server to respond with fake API responses, by using a directory of files for finding out what to say!
213 stars 46 forks source link

enable matching raw request body rather than property-based #96

Closed ftes closed 8 years ago

ftes commented 8 years ago

Hi, I spent quite some time trying to get the following variable response working:

//! body: <someXml>foo</someXml>
<returnXml/>

//! body: <someXml>bar</someXml>
<returnXml2/>

Turns out that wasn't possible. I quick-fixed the code to allow an arbitrary request body string to be matched as well. Before this fix, the code failed in utils.extend() with Fatal error: source.hasOwnProperty is not a function. This was because it expected the request body to be formatted as properties, and so would not accept XML requests.

sideshowcoder commented 8 years ago

Looks good, mind adding a test so we don't break this in the future? Also feel free to add yourself to the Contributors in the README :)

sideshowcoder commented 8 years ago

Ok just some quick style comments and we can get this merged :) Thanks a lot for looking into this!

ftes commented 8 years ago

new proposal :)

sideshowcoder commented 8 years ago

Sorry to create more work for you and being not specific enough :-( hope this makes clearer what I meant as a test, https://github.com/sideshowcoder/canned/blob/master/spec/canned.spec.js#L389

ftes commented 8 years ago

No worries, let's hope we're on the same page this time. I had two small issues with other test cases:

  1. misbehaving util/extends()
  2. different error message than expected

I fixed these as well, let's see what Travis says. I would guess those were OS or version specific bugs.

sideshowcoder commented 8 years ago

Looks good :) I'm gonna merge it later today when I'm back at my own machine and release.

sideshowcoder commented 8 years ago

I merged this with a988f21 I wanted to make sure we don't update the version number just yet as I like to have it in a seperate commit, also squashed down the commits. Thanks for all your work, it is greatly appriciated.

sideshowcoder commented 8 years ago

Ok 0.3.8 has been release thanks again.