Jasmine スパイに、私が期待するように伝えたメッセージだけを聞いて、他のメッセージを無視するように指示するにはどうすればよいですか?
例えば:
例のグループ
describe 'View', ->
describe 'render', ->
beforeEach ->
@view = new View
@view.el = jasmine.createSpyObj 'el', ['append']
@view.render()
it 'appends the first entry to the list', ->
expect(@view.el.append).toHaveBeenCalledWith '<li>First</li>'
it 'appends the second entry to the list', ->
expect(@view.el.append).toHaveBeenCalledWith '<li>Second</li>'
実装
class View
render: ->
@el.append '<li>First</li>', '<li>Second</li>'
出力
View
render
appends the first entry to the list
Expected spy el.append to have been called \
with [ '<li>First</li>' ] but was called \
with [ [ '<li>First</li>', '<li>Second</li>' ] ]
appends the second entry to the list
Expected spy el.append to have been called \
with [ '<li>Second</li>' ] but was called \
with [ [ '<li>First</li>', '<li>Second</li>' ] ]