Skip to content

Instantly share code, notes, and snippets.

@jfromaniello
Created March 2, 2012 14:07
Show Gist options
  • Save jfromaniello/1958575 to your computer and use it in GitHub Desktop.
Save jfromaniello/1958575 to your computer and use it in GitHub Desktop.
//I put this next to the "respondWith" function inside sinon.js
respondWithJson: function (url, responseObject){
this.respondWith(url, [200, {
"Content-Type": "application/json"
}, JSON.stringify(responseObject)]);
},
this.server.requests = [];
//do something that will fire the request
assert... this.server.requests[0].requestBody, $.param({...});
assert... this.server.requests[0].url, my url..
this.server.respondWithJson("/notification/123", [{
Name: "NOTJOSE", Message: "FooBarBaz"}]);
something.doSomethingThatWillFetchTheUrl();
this.server.respond();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment