Created
May 14, 2015 16:15
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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