require '../spec_helper'

describe "Freakset Acceptance", ->

  beforeEach ->
    @freakset = new Freakset()
    @set = null


  it "should compile a Simple Freakset", ->

    @freakset.step "step1", (set) ->
      set.store['steps'].push("step1")
      set.commit()

    @freakset.step "step2", (set) ->
      set.store['steps'].push("step2")
      set.commit()

    @freakset.step (set) ->
      _.delay ( =>
        set.store['steps'].push("step3")
        set.commit()
      ), 200

    @set = @freakset.compile { steps: [] }


    waitsFor -> !@set.isRunning()

    runs ->
      expect(@set.store['steps']).toContain("step1")
      expect(@set.store['steps']).toContain("step2")
      expect(@set.store['steps']).toContain("step3")
