Sha256: 4c39cb0700337b4d871a7a77fb70d7efb0e3943f6017ac04a7c571e71f9b7213

Contents?: true

Size: 1.12 KB

Versions: 9

Compression:

Stored size: 1.12 KB

Contents

require 'helper'

describe "Using timers", acceptance: true do

  define_behavior :shoot_rock do |beh|
    beh.requires :timer_manager
    beh.setup do
      actor.has_attributes rocks_shot: 0
      timer_manager.add_timer 'shoot_rock', 100 do
        actor.react_to :shoot_rock
      end
    end

    react_to do |msg, *args|
      actor.rocks_shot += 1 if msg == :shoot_rock
    end
  end

  define_actor :volcano do
    has_behavior :shoot_rock
  end


  it 'allows behaviors to get fired from timers' do
    game.stage do |stage| # instance of TestingStage
      @counter = 0
      timer_manager.add_timer 'stage_timer', 200 do
        @counter += 1
      end
      create_actor :volcano
    end
    see_actor_attrs :volcano, rocks_shot: 0
    see_stage_ivars counter: 0

    update 10
    see_actor_attrs :volcano, rocks_shot: 0
    see_stage_ivars counter: 0

    update 91
    see_actor_attrs :volcano, rocks_shot: 1
    see_stage_ivars counter: 0

    update 201
    see_actor_attrs :volcano, rocks_shot: 2
    see_stage_ivars counter: 1

    update 1
    see_actor_attrs :volcano, rocks_shot: 3
    see_stage_ivars counter: 1
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gamebox-0.5.5 spec/acceptance/timer_usage_spec.rb
gamebox-0.5.4 spec/acceptance/timer_usage_spec.rb
gamebox-0.5.2 spec/acceptance/timer_usage_spec.rb
gamebox-0.5.1 spec/acceptance/timer_usage_spec.rb
gamebox-0.5.0 spec/acceptance/timer_usage_spec.rb
gamebox-0.4.1 spec/acceptance/timer_usage_spec.rb
gamebox-0.4.0 spec/acceptance/timer_usage_spec.rb
gamebox-0.4.0.rc11 spec/acceptance/timer_usage_spec.rb
gamebox-0.4.0.rc5 spec/acceptance/timer_usage_spec.rb