I’m trying to write a simple spec for a Backbone Todos collection which stubs the Backbone Todo model.
Here’s my spec:
describe "TodoApp.Collections.Todos", ->
beforeEach ->
@todoStub = sinon.stub window, 'TodoApp.Models.Todo'
afterEach ->
@todoStub.restore()
This gives me the following error:
TypeError: Attempted to wrap undefined property TodoApp.Models.Todo as function
The Todo model is defined though as todo = new TodoApp.Models.Todo() doens’t give an error.
Is it a scoping issue? Could somebody point me in the right direction?
I just ran into that problem too. You should call it like this…
instead of this.
this solved the problem for me
@smek: this also solves your problem from http://tinnedfruit.com/2011/03/25/testing-backbone-apps-with-jasmine-sinon-2.html