Skip to content

Instantly share code, notes, and snippets.

@JamesMaroney
Created July 6, 2012 13:19
Show Gist options
  • Save JamesMaroney/3060109 to your computer and use it in GitHub Desktop.
Save JamesMaroney/3060109 to your computer and use it in GitHub Desktop.
'shared/dialog/dialog_view_host': isolate.mapAsFactory (actualDialog, dialogViewName, requestingModule)->
rendermakeSpy = makeSpy 'Isolated Dialog Render'
closeDialog = makeSpy 'Isolated Dialog Close'
fakeDialog = (makeSpy 'Isolated Dialog Initializer').andCall (viewRenderer)->
try
glee.DONT_CALL_INITIALIZE = true
viewRenderer jQuery('<div />'), closeDialog
catch ex
requestingModule = requestingModule.replace(/.*\//,'')
viewName = ex.stack.replace(/^(?:.|\n)*requirements.*\/(.*)\.js(.|\n)*/, '$1')
throw Error "Contract Mismatch rendering view in dialog: #{requestingModule} >>> #{viewName}:\n"+ (+ex || ex.message || ex.toString())
finally
glee.DONT_CALL_INITIALIZE = false
return this
fakeDialog.prototype.render = rendermakeSpy
rendermakeSpy.andReturn fakeDialog
fakeDialog.render = rendermakeSpy
fakeDialog.close = closeDialog
fakeDialog.dialog = makeSpy 'Isolated Dialog.dialog'
for method in ['medium', 'large']
fakeDialog[method] = Spy(method).andCall fakeDialog
return fakeDialog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment