Module: Orocos::Test::Component::ClassExtension
- Defined in:
- lib/orocos/test/component.rb
Overview
Support module for declarations in tests
Instance Method Summary collapse
- #reader(name, port_name, options = Hash.new) ⇒ Object
-
#start(attr_name, *options) ⇒ Object
Starts a new task context on test setup and assigns it to a local variable.
- #writer(name, port_name, options = Hash.new) ⇒ Object
Instance Method Details
#reader(name, port_name, options = Hash.new) ⇒ Object
187 188 189 190 191 192 193 194 195 |
# File 'lib/orocos/test/component.rb', line 187 def reader(name, port_name, = Hash.new) if .respond_to?(:to_str) = { :attr_name => } end , policy = Kernel. , :attr_name => "#{name}_#{port_name}" attr_reader [:attr_name] reader_specs << [name, port_name, [:attr_name], policy] end |
#start(attr_name, task_name, run_spec) ⇒ Object #start(attr_name, run_spec) ⇒ Object
Starts a new task context on test setup and assigns it to a local variable
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
176 177 178 179 180 181 182 183 184 185 |
# File 'lib/orocos/test/component.rb', line 176 def start(attr_name, *) attr_reader attr_name if .size == 2 run_specs << [attr_name, *] elsif .size == 1 run_specs << [attr_name, attr_name, *] else raise ArgumentError, "expected two or three arguments, got #{.size}" end end |
#writer(name, port_name, options = Hash.new) ⇒ Object
197 198 199 200 201 202 203 204 205 |
# File 'lib/orocos/test/component.rb', line 197 def writer(name, port_name, = Hash.new) if .respond_to?(:to_str) = { :attr_name => } end , policy = Kernel. , :attr_name => "#{name}_#{port_name}" attr_reader [:attr_name] writer_specs << [name, port_name, [:attr_name], policy] end |