class Roby::Test::ValidateStateMachine
Implementation of the validate_state_machine context
Public Class Methods
new(test, task_or_action)
click to toggle source
# File lib/roby/test/validate_state_machine.rb, line 5 def initialize(test, task_or_action) @test = test @toplevel_task = @test.roby_run_planner(task_or_action) @state_machines = @toplevel_task.each_coordination_object. find_all { |obj| obj.kind_of?(Coordination::ActionStateMachine) } if @state_machines.empty? raise ArgumentError, "#{task_or_action} has no state machines" end end
Public Instance Methods
assert_transitions_to_state(state_name, timeout: 5, start: true) { || ... }
click to toggle source
# File lib/roby/test/validate_state_machine.rb, line 16 def assert_transitions_to_state(state_name, timeout: 5, start: true) if state_name.respond_to?(:to_str) && !state_name.end_with?('_state') state_name = "#{state_name}_state" end done = false @state_machines.each do |m| m.on_transition do |_, new_state| if state_name === new_state.name done = true end end end yield if block_given? @test.process_events_until(timeout: timeout, garbage_collect_pass: false) do done end @test.roby_run_planner(@toplevel_task) state_task = @toplevel_task.current_task_child if start expect_execution.to { emit state_task.start_event } end state_task end
evaluate(&block)
click to toggle source
# File lib/roby/test/validate_state_machine.rb, line 41 def evaluate(&block) instance_eval(&block) end
find_through_method_missing(m, args)
click to toggle source
Calls superclass method
# File lib/roby/test/validate_state_machine.rb, line 45 def find_through_method_missing(m, args) MetaRuby::DSLs.find_through_method_missing( @toplevel_task, m, args, '_event' => :find_event, '_child' => :find_child_from_role) || super end
has_through_method_missing?(m)
click to toggle source
Calls superclass method
# File lib/roby/test/validate_state_machine.rb, line 52 def has_through_method_missing?(m) MetaRuby::DSLs.has_through_method_missing?( @toplevel_task, m, '_event' => :has_event?, '_child' => :has_role?) || super end
method_missing(m, *args, &block)
click to toggle source
Calls superclass method
# File lib/roby/test/validate_state_machine.rb, line 65 def method_missing(m, *args, &block) if @test.respond_to?(m) @test.public_send(m, *args, &block) else super end end
respond_to_missing?(m, include_private)
click to toggle source
Calls superclass method
# File lib/roby/test/validate_state_machine.rb, line 61 def respond_to_missing?(m, include_private) @test.respond_to?(m) || super end