Sha256: 16472f2b6e5272018e28e7cf395a9becd8c96eaf3d7f45c96c87cf4eee9d5785

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 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_should_behave_like 'MonkeyAction'

  it '@it should be the correct type' do
    @it.is_a?(MonkeyActionWake).should == 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 == true
  end

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

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

  # validate
  it 'should 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

1 entries across 1 versions & 1 rubygems

Version Path
MonkeyEngine-2.0.0 spec/monkey_action_wake_spec.rb