Sha256: 48ff99c8f88ed22fd750f9cd9d83dc465afa01dfe90e7d222ba07216fe351a14

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

class SpecPerimeter < Kindergarten::Perimeter
  purpose :testing

  governess Kindergarten::StrictGoverness

  govern do
    can :view, String
  end

  subscribe :eating, :eat, :evented
  subscribe :puppets, :play, lambda { |event, purpose|
    purpose.sandbox.testing.dress!
  }

  # should pass and return the child
  def sandboxed
    guard(:view, child)
  end

  # should raise AccessDenied
  def guarded
    guard(:somethings, child)
  end

  # should not be accessible
  def unboxed
    $stderr.puts "I should never happen"
  end

  # should return "OK"
  def not_guarded
    unguarded
    "OK"
  end

  # should raise Unguarded
  def unsafe
    return child.reverse
  end

  # happens on dining.eat event
  def evented
    @evented = true
  end

  def evented?
    @evented == true ? true : false
  end

  expose :dress!
  def dress!
    unguarded
    @dressed = true
  end

  def puppet_dressed?
    unguarded
    @dressed == true ? true : false
  end

  sandbox :sandboxed, :not_guarded, :guarded, :unsafe, :evented
  expose :puppet_dressed?
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kindergarten-0.2.1 spec/support/spec_perimeter.rb
kindergarten-0.2.0 spec/support/spec_perimeter.rb
kindergarten-0.1.1 spec/support/spec_perimeter.rb