Created
July 29, 2012 16:16
-
-
Save yangchenyun/3200012 to your computer and use it in GitHub Desktop.
stub test
This file contains 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
describe "calculator", -> | |
it "should call the given method when parameter is valid", -> | |
# stub the method instead of just 'spying' it | |
minusStub = sinon.stub sample, 'minus' | |
methods = ['multiple', 'addition', 'minus', 'divide'] | |
sample.calculator('minus', 1) | |
sinon.assert.calledOnce(minusStub) | |
sinon.assert.calledWithExactly(minusStub, [1]) | |
# restore the minus method | |
minusStub.restore() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment