Created
December 11, 2012 01:23
-
-
Save tatsuro-ueda/4254956 to your computer and use it in GitHub Desktop.
Jasmine Spy on CoffeeScript
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
# 「JS開発におけるTDDと自動テストツール利用の勘所 」より引用。 | |
# http://www.slideshare.net/KojiNakamura/jstdd | |
it "should be called", -> | |
obj = | |
method: -> | |
spyOn obj, "method" # spyOnメソッドでオブジェクトの特定メソッドをスパイ化 | |
obj.method() | |
expect(obj.method).toHaveBeenCalled() # spy用のMatcherが用意されている | |
test "should be called", -> | |
spy = jasmine.createSpy() # スパイ化された関数オブジェクトを作成する | |
spy() | |
expect(spy).toHaveBeenCalled() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment