module Orocos::Test::Component::ClassExtension
Support module for declarations in tests
Public Instance Methods
reader(name, port_name, options = Hash.new)
click to toggle source
# File lib/orocos/test/component.rb, line 187 def reader(name, port_name, options = Hash.new) if options.respond_to?(:to_str) options = { :attr_name => options } end options, policy = Kernel.filter_options options, :attr_name => "#{name}_#{port_name}" attr_reader options[:attr_name] reader_specs << [name, port_name, options[:attr_name], policy] end
start(attr_name, *options)
click to toggle source
Starts a new task context on test setup and assigns it to a local variable
@overload start(attr_name, task_name, run_spec)
@param [String,Symbol] attr_name the attribute name
@param [String] task_name the name of the orocos task that
should be assigned to
@param [Hash] run_spec arguments that should be passed to
{Orocos.run}. Once Orocos.run is called, there should
exists a task called task_name
@overload start(attr_name, run_spec)
@param [String,Symbol] attr_name the attribute name as well
as the orocos task name. See above.
@param [Hash] run_spec arguments that should be passed to
{Orocos.run}. Once Orocos.run is called, there should
exists a task called attr_name
Requires the unit test to start a deployment/task at startup and shut it down during teardown. In test methods, the task object can be accessed as the attr_name attribute
@example start a task context and tests that configuration fails
require 'minitest/spec' require 'orocos/test/component' describe 'xsens_imu::Task' do include Orocos::Test::Component start 'task', 'xsens_imu::Task' => 'task' def test_configure_fails_if_no_device_is_present task.device = "" assert_raises(Orocos::StateTransitionFailed) { task.configure } end end
# File lib/orocos/test/component.rb, line 176 def start(attr_name, *options) attr_reader attr_name if options.size == 2 run_specs << [attr_name, *options] elsif options.size == 1 run_specs << [attr_name, attr_name, *options] else raise ArgumentError, "expected two or three arguments, got #{options.size}" end end
writer(name, port_name, options = Hash.new)
click to toggle source
# File lib/orocos/test/component.rb, line 197 def writer(name, port_name, options = Hash.new) if options.respond_to?(:to_str) options = { :attr_name => options } end options, policy = Kernel.filter_options options, :attr_name => "#{name}_#{port_name}" attr_reader options[:attr_name] writer_specs << [name, port_name, options[:attr_name], policy] end