Class: Megatest::Test
- Inherits:
-
Object
- Object
- Megatest::Test
- Extended by:
- DSL
- Includes:
- Assertions, Stubs
- Defined in:
- lib/megatest/test.rb
Overview
Subclass Test to define a test suite
See Megatest::Assertions and Megatest::DSL
Instance Method Summary collapse
-
#__config__ ⇒ Object
Returns the global megatest config object.
-
#__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 Stubs
#stub, #stub_any_instance_of, #stub_const
Methods included from Assertions
#assert, #assert_changes, #assert_difference, #assert_empty, #assert_equal, #assert_in_delta, #assert_in_epsilon, #assert_includes, #assert_instance_of, #assert_kind_of, #assert_match, #assert_nil, #assert_nothing_raised, #assert_operator, #assert_output, #assert_predicate, #assert_raises, #assert_respond_to, #assert_same, #assert_silent, #assert_throws, #capture_io, #flunk, #pass, #refute, #refute_changes, #refute_difference, #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.
73 74 75 |
# File 'lib/megatest/test.rb', line 73 def initialize(runtime) @__m = runtime end |
Instance Method Details
#__config__ ⇒ Object
Returns the global megatest config object.
112 113 114 |
# File 'lib/megatest/test.rb', line 112 def __config__ @__m.config end |
#__result__ ⇒ Object
Returns the current Megatest::TestCaseResult instance Can be used for self introspection during teardown
118 119 120 |
# File 'lib/megatest/test.rb', line 118 def __result__ @__m.result end |
#__test__ ⇒ Object
Returns the current Megatest::State::TestCase instance Can be used for self introspection
107 108 109 |
# File 'lib/megatest/test.rb', line 107 def __test__ @__m.test_case end |
#after_setup ⇒ Object
88 89 |
# File 'lib/megatest/test.rb', line 88 def after_setup end |
#after_teardown ⇒ Object
97 98 |
# File 'lib/megatest/test.rb', line 97 def after_teardown end |
#before_setup ⇒ Object
77 78 |
# File 'lib/megatest/test.rb', line 77 def before_setup end |
#before_teardown ⇒ Object
91 92 |
# File 'lib/megatest/test.rb', line 91 def before_teardown end |
#include(*modules) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/megatest/test.rb', line 39 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
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/megatest/test.rb', line 19 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
81 82 83 |
# File 'lib/megatest/test.rb', line 81 def name @__m.test_case.name end |
#setup ⇒ Object
85 86 |
# File 'lib/megatest/test.rb', line 85 def setup end |
#teardown ⇒ Object
94 95 |
# File 'lib/megatest/test.rb', line 94 def teardown end |