Skip to content

Instantly share code, notes, and snippets.

@yashke
Created February 5, 2012 21:26
Show Gist options
  • Select an option

  • Save yashke/1748016 to your computer and use it in GitHub Desktop.

Select an option

Save yashke/1748016 to your computer and use it in GitHub Desktop.

Revisions

  1. yashke renamed this gist Feb 5, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. yashke created this gist Feb 5, 2012.
    19 changes: 19 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    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")