Skip to content

Instantly share code, notes, and snippets.

@thurloat
Created January 13, 2012 14:50
Show Gist options
  • Select an option

  • Save thurloat/1606661 to your computer and use it in GitHub Desktop.

Select an option

Save thurloat/1606661 to your computer and use it in GitHub Desktop.
Awesome function spying
it 'should fail if end date is after start date', ->
testTrip = new Trip
errorSpy = do sinon.spy
testTrip.set
end: '01/13/2012'
start: '02/14/2012',
error: errorSpy
expect(testTrip.get('start')).not.toEqual('02/14/2012')
expect(testTrip.get('end')).not.toEqual('01/13/2012')
expect(errorSpy.calledOnce).toBeTruthy()
expect(errorSpy.calledWith testTrip, "It can't start before it ends").toBeTruthy()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment