Skip to content

Instantly share code, notes, and snippets.

@gotascii
Created April 25, 2011 11:37
Show Gist options
  • Save gotascii/940398 to your computer and use it in GitHub Desktop.
Save gotascii/940398 to your computer and use it in GitHub Desktop.
simple node stubs
stubs = []
module.exports =
stub: (obj, name, fun) ->
stubs.push({'obj':obj, 'name':name, 'fun':obj[name]})
obj[name] = if fun? then fun else ->
unstub: ->
for stubbed in stubs
stubbed.obj[stubbed.name] = stubbed.fun
stubs.length = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment