Skip to content

Instantly share code, notes, and snippets.

@anoras
Created October 11, 2011 19:45
Show Gist options
  • Select an option

  • Save anoras/1279179 to your computer and use it in GitHub Desktop.

Select an option

Save anoras/1279179 to your computer and use it in GitHub Desktop.
Backbone.js and spies
@Vis=
Routers: {}
Collections: {}
Models: {}
Views: {}
init: (args) ->
args = {} unless args?
args['router'] = new Vis.Routers.Main() unless args['router']?
args['route'] = '' unless args['route']?
@router = args['router']
Backbone.history.start({silent: true, pushState: true})
@router.navigate(args['route'])
Snehvit:web_app anders$ guard-jasmine
Run Jasmine at http://127.0.0.1:3000/jasmine
{
"passed": false,
"stats": {
"specs": 1,
"failures": 1,
"time": 0.006
},
"suites": [
{
"description": "Vis",
"specs": [
{
"description": "Vis should default to the Main router unless a route is injected.",
"passed": false,
"error_message": "TypeError: Result of expression 'this._bindRoutes' [undefined] is not a function. in http://127.0.0.1:3000/assets/backbone.js?body=1 (line 661)"
}
]
}
]
}
describe "Vis", ->
it "should default to the Main router unless a route is injected", ->
spyOn(window.Vis.Routers,"Main").andCallThrough()
window.Vis.init()
expect(window.Vis.Routers.Main).toHaveBeenCalled()
@anoras
Copy link
Author

anoras commented Feb 7, 2012

I solved it, but I cannot recall how. Tried to find an old Twitter conversation about this, but Twitter search kind of sucks. Think I switched to using Sinon.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment