Sha256: 94353f22ba6bdec8d2e36b6f794bf290cb51c616ddb4d25a1bee82ab183134da

Contents?: true

Size: 1.52 KB

Versions: 5

Compression:

Stored size: 1.52 KB

Contents

require File.join(File.dirname(__FILE__),'helper')
require 'actor'
require 'behavior'

describe 'A new actor' do
  before do
    opts = {:stage=>"stage", :input=>"input", 
      :resources=>"resource", :actor_type => :actor}
    @actor = Actor.new opts
  end

  it 'should be alive' do
    @actor.alive?.should be_true
  end

  it 'should be the correct type' do
    @actor.actor_type.should == :actor
  end

  it 'should be at (0,0)' do
    @actor.x.should equal(0)
    @actor.y.should equal(0)
  end

  it 'should have access to backstage' do
    @actor.stage = mock(:backstage => :stuff)
    @actor.backstage.should == :stuff
  end

  it 'should have atts set' do
    @actor.stage.should == "stage" 
    @actor.input_manager.should == "input" 
    @actor.resource_manager.should == "resource" 
    @actor.behaviors.size.should equal(0)
  end

  it 'should fire anything' do
    Proc.new {
      @actor.when :foofoo_bar do
        "blah"
      end
    }.should_not raise_error
  end

  it 'should inherit parents behaviors' do
    @shawn = Shawn.new {}
    @shawn.is?(:smart).should be_true
  end

  it 'should be able to override parents behaviors' do
    @james = JamesKilton.new {}
    @james.is?(:smart).should be_true
    @james.instance_variable_get('@behaviors')[:smart].instance_variable_get('@opts').should == {:really=>true}
  end
end

class Cool < Behavior; end
class Smart < Behavior; end
class Coder < Actor
  has_behavior :smart, :cool
end
class Shawn < Coder; end
class JamesKilton < Coder
  has_behavior :smart => {:really => true}
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gamebox-0.2.1 spec/actor_spec.rb
gamebox-0.1.1 spec/actor_spec.rb
gamebox-0.1.0 spec/actor_spec.rb
gamebox-0.0.9 spec/actor_spec.rb
gamebox-0.0.8 spec/actor_spec.rb