I’ve discovered an even cooler mechanism, using jasmine.any()
, as I find taking the arguments apart by hand to be sub-optimal for legibility.
In CoffeeScript:
obj = {}
obj.method = (arg1, arg2) ->
describe "callback", ->
it "should be called with 'world' as second argument", ->
spyOn(obj, 'method')
obj.method('hello', 'world')
expect(obj.method).toHaveBeenCalledWith(jasmine.any(String), 'world')