-
-
Save cymen/3875554 to your computer and use it in GitHub Desktop.
Auto-restoring sinon fakes with Konacha
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# require spec_helper | |
Test = | |
fn: -> 'result' | |
it 'auto-resets sinon fakes', -> | |
@stub(Test, 'fn') | |
Test.fn() | |
Test.fn.should.have.been.called | |
it 'has been reset', -> | |
Test.fn().should.equal('result') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Injected by sinon.js | |
Konacha.mochaOptions.globals = [ | |
'XMLHttpRequest' | |
'setTimeout' | |
'setInterval' | |
'clearTimeout' | |
'clearInterval' | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#= require support/sinon | |
#= require support/sinon-chai | |
window.chai.use(window.sinonChai) | |
beforeEach -> | |
@sandbox = sinon.sandbox.create | |
injectInto: this | |
properties: ["spy", "stub", "mock", "clock", "server", "requests"], | |
useFakeTimers: true, | |
useFakeServer: true | |
afterEach -> | |
@sandbox.restore() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment