Sha256: b0381097b9170a62a7110312713a0e9df56f235202bbf24d1568d05f753e4ce7
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
# frozen_string_literal: true require 'Monkey' require 'MonkeyFactory' require 'MonkeyEngine' require 'MonkeyManager' require 'MonkeyActions' require_relative '../lib/MonkeyKeyboard/keyboard_input' describe 'ActionRules' do before(:each) do end after(:all) do end context 'get_next_action' do it 'should throw an exception if the action is not completed' do monkey = MonkeyFactory.create :groucho monkey.extend(SpecHelpers::SetMonkeyAction) keyboard_input = KeyboardInput.new keyboard_input.input = %w[H e l l o] action = MonkeyActionType.new(monkey, keyboard_input) action.action_completed = false monkey.set_action(action) lambda { ActionRules.instance.get_next_action monkey }.should raise_error MonkeyEngine::Exceptions::InvalidOperationException end it 'should get correct action if current action is nil?' do monkey = MonkeyFactory.create :groucho monkey.extend(SpecHelpers::SetMonkeyAction) monkey.set_action(nil) ActionRules.instance.get_next_action(monkey).is_a?(MonkeyActionWake).should == true end it 'should get correct action if current action is MonkeyActionSleep' do monkey = MonkeyFactory.create :groucho monkey.extend(SpecHelpers::SetMonkeyAction) action = MonkeyActionSleep.new(monkey, 6 * 60) action.action_completed = true monkey.set_action(action) ActionRules.instance.get_next_action(monkey).is_a?(MonkeyActionWake).should == true end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
MonkeyEngine-2.0.0 | spec/action_rules_spec.rb |