Preventing AJAX call with Jasmine and Sinon using Backbone
问题 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