Sha256: 4a3cc656c9dd2683b8105cb64d62ddb6ae975fdb33edd700a7ab97cb45b5beb1

Contents?: true

Size: 1.32 KB

Versions: 7

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

require 'Monkey'
require 'MonkeyActions'
require 'MonkeyFactory'
require 'MonkeyEngine'

require_relative 'support/shared_examples'

describe 'MonkeyActionWake' do
  before(:all) do
    @monkey = MonkeyFactory.create :waking_monkey1
    @it = MonkeyActionWake.new @monkey

    MonkeyEngine::MonkeyManager.instance.add(@monkey)
  end

  after(:all) do
    # Kill all the threads.
    MonkeyEngine::MonkeyManager.instance.kill_all!

    # Give them a little bit to finish.
    MonkeyEngine::MonkeyManager.instance.join_all(10)
  end

  it_behaves_like 'MonkeyAction'

  it '@it should be the correct type' do
    @it.is_a?(MonkeyActionWake).should be true
  end

  # Monkey
  it '@monkey should be the same monkey' do
    @it.monkey.should == @monkey
  end

  # Value
  it '@value should return the right value' do
    @it.value.should be true
  end

  it '@value should be is_a? TrueClass' do
    @it.value.is_a?(TrueClass).should be true
  end

  # Weight
  it '@weight should return the right weight' do
    @it.weight.should == MonkeyActionWake::WEIGHT
  end

  # validate
  it 'does not raise an error if value is within acceptable range' do
    monkey = MonkeyFactory.create(:waking_monkey2)
    MonkeyEngine::MonkeyManager.instance.add(monkey)
    -> { MonkeyActionWake.new(monkey) }.should_not raise_error
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
MonkeyEngine-2.0.7 spec/monkey_action_wake_spec.rb
MonkeyEngine-2.0.6 spec/monkey_action_wake_spec.rb
MonkeyEngine-2.0.5 spec/monkey_action_wake_spec.rb
MonkeyEngine-2.0.4 spec/monkey_action_wake_spec.rb
MonkeyEngine-2.0.3 spec/monkey_action_wake_spec.rb
MonkeyEngine-2.0.2 spec/monkey_action_wake_spec.rb
MonkeyEngine-2.0.1 spec/monkey_action_wake_spec.rb