require '../spec_helper'

describe "Freakset Acceptance", ->
  
  beforeEach ->
    @freakset = Freakset.build()
    @set = null
   

  it "should compile a Simple Guarded Freakset", ->

    @freakset.step "step1", (set) ->
      set.store['steps'].push("step1")
      set.commit()
    
    @freakset.guard "guard:steps", (set) ->
      set.store['steps'].indexOf('step1') isnt -1
    
    @freakset.step "step2", (set) ->
      set.store['steps'].push("step2")
      set.commit()
      
    @freakset.guard "guard:steps", (set) ->
      set.store['steps'].indexOf('stepX') isnt -1
      
    @freakset.step "step3", (set) ->
      set.store['steps'].push("step3")
      set.commit()
    
    @set = @freakset.compile { steps: [] }
    
    
    waitsFor -> !@set.isRunning()
    
    runs ->
      expect(@set.store['steps']).toContain("step1")
      expect(@set.store['steps']).toContain("step2")
      expect(@set.store['steps']).not.toContain("step3")