Skip to content

Instantly share code, notes, and snippets.

@jbpros
Created October 27, 2011 12:36
Show Gist options
  • Save jbpros/1319436 to your computer and use it in GitHub Desktop.
Save jbpros/1319436 to your computer and use it in GitHub Desktop.
Create an "uninitialized" object in your jasmine specs
global.newUninitialized = (klass) ->
createInstanceOfKlass = (() ->
F = (args) ->
klass.apply(this, args)
F.prototype = klass.prototype
() ->
new F(arguments);
)()
args = []
Array.prototype.push.apply(args, arguments)
args.shift()
originalInitialize = klass.prototype.initialize
klass.prototype.initialize = () ->
instance = createInstanceOfKlass.apply(this, args)
klass.prototype.initialize = originalInitialize
instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment