I'm just getting started testing my Backbone app with Sinon and Jasmine. I have a view that look something like (coffeescript):
initialize: ->
@collection.on 'reset', @render, this
render: ->
if @collection.fetched
# do stuff
else
@$el.append "<h3>Loading...</h3>"
@collection.fetch()
this
I want to test this with an unfetched collection, but I'm not sure how to fake an ajax call within my code (obviously can easily be done in the spec). I realize that I could just pass in a pre-fetched collection, but I'm curious -- is it possible with Sinon to override the fetch function to return a fake response?
Thank you for any help.