require '../../../../spec_helper'

describe "Freakset.Actor.Step", ->

  beforeEach ->
    @Step = Freakset.Actor.Step
    @freakset = {
      modifyStack: jasmine.createSpy(),
      stack: []
    }

  describe '#build', ->

    it 'should append a actor definition to the stack', ->
      @Step.build @freakset, "spec:scope", ->
      expect(@freakset.modifyStack).toHaveBeenCalled()

    it 'should attach type, scope and callback to the stack', ->
      fn = ->
      @Step.build @freakset, "spec:step", fn
      expect(@freakset.modifyStack.mostRecentCall.args[1]).toEqual { type: "step", scope: "spec:step", fn: fn }

  describe '#run', ->

    it 'should run the actor in the context of the freakset', ->
      fn = jasmine.createSpy()
      @Step.run(@freakset, { type: "step", fn: fn })
      expect(fn).toHaveBeenCalledWith(@freakset)
