Skip to content

Instantly share code, notes, and snippets.

@yashke
Created February 5, 2012 21:26
Show Gist options
  • Save yashke/1748016 to your computer and use it in GitHub Desktop.
Save yashke/1748016 to your computer and use it in GitHub Desktop.
class ServerSideStub
createToken: (callback) =>
callback("token")
describe "SomeUsecase", ->
beforeEach ->
@serverSide = new ServerSideStub()
@usecase = new SomeUsecase(@serverSide)
describe "#execute", ->
it "should call ServerSide#createToken", ->
spyOn(@serverSide, 'createToken')
@usecase.execute("kaka")
expect(@serverSide.createToken).toHaveBeenCalled()
it "should run #doSmthWith as callback with name and returned token", ->
spyOn(@usecase, 'doSmthWith').andFakeCall(=> null)
@usecase.execute("kaka")
expect(@usecase.doSmthWith).toHaveBeenCalledWith("token", "name")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment