Skip to content

Instantly share code, notes, and snippets.

@StevenLangbroek
Created October 2, 2014 15:52
Show Gist options
  • Select an option

  • Save StevenLangbroek/98be7a6ee4d013029ecf to your computer and use it in GitHub Desktop.

Select an option

Save StevenLangbroek/98be7a6ee4d013029ecf to your computer and use it in GitHub Desktop.
Sync example
describe "Saving", ->
before ->
@syncSpy = sinon.spy()
@syncStub = sinon.stub(Backbone, 'sync', @syncSpy)
@changeSpy = sinon.spy()
afterEach ->
@syncSpy.reset()
it 'sets errors on the model when trying to save', ->
application.on('change:_errors', @changeSpy)
application.save(null, validate: true)
@changeSpy.should.have.been.calledOnce
@syncSpy.should.not.have.been.called
it 'should skip validation by default', ->
application.save()
@syncSpy.calledWith('create', application, sinon.match.any).should.be.ok
@syncSpy.should.be.calledOnce
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment