Created
October 11, 2011 19:45
-
-
Save anoras/1279179 to your computer and use it in GitHub Desktop.
Backbone.js and spies
This file contains hidden or 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
| @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']) |
This file contains hidden or 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
| 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)" | |
| } | |
| ] | |
| } | |
| ] | |
| } |
This file contains hidden or 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
| 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() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.