Class: Megatest::Test
- Inherits:
-
Object
- Object
- Megatest::Test
- Extended by:
- DSL
- Includes:
- Assertions
- Defined in:
- lib/megatest/test.rb
Overview
Subclass Test to define a test suite
See Megatest::Assertions and Megatest::DSL
Instance Method Summary collapse
-
#__result__ ⇒ Object
Returns the current Megatest::TestCaseResult instance Can be used for self introspection during teardown.
-
#__test__ ⇒ Object
Returns the current Megatest::State::TestCase instance Can be used for self introspection.
- #after_setup ⇒ Object
- #after_teardown ⇒ Object
- #before_setup ⇒ Object
- #before_teardown ⇒ Object
- #include(*modules) ⇒ Object
- #inherited(subclass) ⇒ Object
-
#initialize(runtime) ⇒ Test
constructor
A new instance of Test.
-
#name ⇒ Object
For Minitest compatibility.
- #setup ⇒ Object
- #teardown ⇒ Object
Methods included from DSL
around, context, extended, method_added, tag, test
Methods included from Assertions
#assert, #assert_empty, #assert_equal, #assert_in_delta, #assert_in_epsilon, #assert_includes, #assert_instance_of, #assert_kind_of, #assert_match, #assert_nil, #assert_operator, #assert_output, #assert_predicate, #assert_raises, #assert_respond_to, #assert_same, #assert_silent, #assert_throws, #capture_io, #flunk, #pass, #refute, #refute_empty, #refute_equal, #refute_in_delta, #refute_in_epsilon, #refute_includes, #refute_instance_of, #refute_kind_of, #refute_match, #refute_nil, #refute_operator, #refute_predicate, #refute_respond_to, #refute_same, #skip
Constructor Details
#initialize(runtime) ⇒ Test
Returns a new instance of Test.
72 73 74 |
# File 'lib/megatest/test.rb', line 72 def initialize(runtime) @__m = runtime end |
Instance Method Details
#__result__ ⇒ Object
Returns the current Megatest::TestCaseResult instance Can be used for self introspection during teardown
111 112 113 |
# File 'lib/megatest/test.rb', line 111 def __result__ @__m.result end |
#__test__ ⇒ Object
Returns the current Megatest::State::TestCase instance Can be used for self introspection
105 106 107 |
# File 'lib/megatest/test.rb', line 105 def __test__ @__m.test_case end |
#after_setup ⇒ Object
87 88 |
# File 'lib/megatest/test.rb', line 87 def after_setup end |
#after_teardown ⇒ Object
96 97 |
# File 'lib/megatest/test.rb', line 96 def after_teardown end |
#before_setup ⇒ Object
76 77 |
# File 'lib/megatest/test.rb', line 76 def before_setup end |
#before_teardown ⇒ Object
90 91 |
# File 'lib/megatest/test.rb', line 90 def before_teardown end |
#include(*modules) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/megatest/test.rb', line 38 def include(*modules) super location = Thread.each_caller_location do |l| break l if l.base_label != "include" && !l.path.start_with?("<internal:") end include_location = [location.path, location.lineno] modules.each do |mod| if mod.is_a?(::Megatest::DSL) || mod.instance_methods.any? { |m| m.start_with?("test_") } ::Megatest.registry.shared_suite(mod).included_by(self, include_location) end end end |
#inherited(subclass) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/megatest/test.rb', line 18 def inherited(subclass) super const_source_location = if subclass.name ::Object.const_source_location(subclass.name) else location = caller_locations.find { |l| l.base_label != "inherited" && !l.path.start_with?("<internal:") } [location.path, location.lineno] end ::Megatest.registry.register_suite(subclass, const_source_location) end |
#name ⇒ Object
For Minitest compatibility
80 81 82 |
# File 'lib/megatest/test.rb', line 80 def name @__m.test_case.name end |
#setup ⇒ Object
84 85 |
# File 'lib/megatest/test.rb', line 84 def setup end |
#teardown ⇒ Object
93 94 |
# File 'lib/megatest/test.rb', line 93 def teardown end |