Skip to content

Instantly share code, notes, and snippets.

@jaw187
Created May 14, 2015 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaw187/17d6e95896c65647b02c to your computer and use it in GitHub Desktop.
Save jaw187/17d6e95896c65647b02c to your computer and use it in GitHub Desktop.
A monkey patch which will override a method and throw an error after method is run a specific number of times
exports.forceWreckError = function (method, timer) {
var original = Wreck[method];
Wreck[method] = function () {
if (!timer) {
var callback = arguments[arguments.length - 1];
Wreck[method] = original;
return callback(new Error('foo'));
}
--timer;
return original.apply(Wreck, arguments);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment