Class: Test
- Inherits:
-
Gloo::Core::Obj
- Object
- Gloo::Core::Obj
- Test
- Defined in:
- lib/test.rb
Overview
A gloo unit test object
Constant Summary collapse
- KEYWORD =
'test'.freeze
- TEST_DESC =
'description'.freeze
- ON_TEST_EVENT =
'on_test'.freeze
Class Method Summary collapse
-
.doc_data ⇒ Object
Get the object's documentation data.
-
.messages ⇒ Object
Get a list of message names that this object receives.
-
.short_typename ⇒ Object
The short name of the object type.
-
.typename ⇒ Object
The name of the object type.
Instance Method Summary collapse
-
#add_children_on_create? ⇒ Boolean
Does this object have children to add when an object is created in interactive mode? This does not apply during obj load, etc.
-
#add_default_children ⇒ Object
Add children to this object.
-
#run_on_test ⇒ Object
Run the on_test script.
-
#run_test ⇒ Object
Run the test.
-
#test_desc ⇒ Object
Get the test description.
Class Method Details
.doc_data ⇒ Object
Get the object's documentation data.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/test.rb', line 98 def self.doc_data { :name => KEYWORD, :shortcut => KEYWORD, :description => 'A single gloo test.', :children => [ 'description (string) — A textual description of the test and desired outcome, used in output if there is an error.', 'on_test (script) — The script to run when the test is executed. Note that the normal way to run tests is with gloo --test.' ], :examples => <<~EXAMPLES.strip # # Basic tests # tests [can] : basic [can] : on_load [script] : log 'Include functionality for all test in on_load' (debug) assert_noop [test] : description [string] : Assert no operation on_test [script] : noop assert 'noop should be true' EXAMPLES } end |
.messages ⇒ Object
Get a list of message names that this object receives.
63 64 65 |
# File 'lib/test.rb', line 63 def self. return super # + [ 'run' ] end |
.short_typename ⇒ Object
The short name of the object type. Same as the typename.
22 23 24 |
# File 'lib/test.rb', line 22 def self.short_typename return KEYWORD end |
.typename ⇒ Object
The name of the object type.
14 15 16 |
# File 'lib/test.rb', line 14 def self.typename return KEYWORD end |
Instance Method Details
#add_children_on_create? ⇒ Boolean
Does this object have children to add when an object is created in interactive mode? This does not apply during obj load, etc.
42 43 44 |
# File 'lib/test.rb', line 42 def add_children_on_create? return true end |
#add_default_children ⇒ Object
Add children to this object. This is used by containers to add children needed for default configurations.
49 50 51 52 53 |
# File 'lib/test.rb', line 49 def add_default_children fac = @engine.factory fac.create_string TEST_DESC, '', self fac.create_script ON_TEST_EVENT, '', self end |
#run_on_test ⇒ Object
Run the on_test script.
84 85 86 87 88 89 |
# File 'lib/test.rb', line 84 def run_on_test o = find_child ON_TEST_EVENT return unless o Gloo::Exec::Dispatch.( @engine, 'run', o ) end |
#run_test ⇒ Object
Run the test.
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/test.rb', line 70 def run_test result = Result.new( @engine, self ) @engine.context_object = result run_on_test @engine.context_object = nil result.show_result_symbol return result end |
#test_desc ⇒ Object
Get the test description.
29 30 31 32 |
# File 'lib/test.rb', line 29 def test_desc o = find_child TEST_DESC return o ? o.value : 'Unknown' end |