Class: QuickTest::TestRunner
- Inherits:
-
Object
- Object
- QuickTest::TestRunner
- Defined in:
- lib/quicktest.rb
Overview
to reuse this implementation
-
create a module specific to the testing system
-
and then add a flag at the bottom of this file to set QuickTest.runner_module to the new module
The module should
-
implement any methods to be publicly available in the quicktest method
-
contain the constants
-
QuickTestIgnoreClasses
-
QuickTestIncludeModules
-
see RSpecTestRunner as an example
it is possible to write a test runner without re-using this code. The test runner class to be used is set at the bottom of this file with QuickTest.runner =
Class Attribute Summary collapse
-
.methods ⇒ Object
Returns the value of attribute methods.
-
.tested_self ⇒ Object
Returns the value of attribute tested_self.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(tested) ⇒ TestRunner
constructor
A new instance of TestRunner.
Constructor Details
#initialize(tested) ⇒ TestRunner
Returns a new instance of TestRunner.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/quicktest.rb', line 58 def initialize tested self.class.tested_self = tested q = tested.method(QuickTest.test_method) tested.extend(QuickTest.runner_module) QuickTest.runner_module::QuickTestIncludeModules.each do |mod| tested.extend mod end case q.arity when 0 then q.call when 1 then q.call tested.method(self.class.methods[-1]) else raise ArgumentError, "to many arguments for #{QuickTest.test_method} method" end tested.send :__quicktest_run_tests__ # removing the quicktest method will prevent Ruby from warning about the method being redefined # I don't know how to remove a class method unless tested.kind_of?(Class) or tested.kind_of?(Module) tested.class.class_eval { remove_method QuickTest.test_method } end end |
Class Attribute Details
.methods ⇒ Object
Returns the value of attribute methods.
46 47 48 |
# File 'lib/quicktest.rb', line 46 def methods @methods end |
.tested_self ⇒ Object
Returns the value of attribute tested_self.
46 47 48 |
# File 'lib/quicktest.rb', line 46 def tested_self @tested_self end |
Class Method Details
.add_method(meth) ⇒ Object
51 52 53 |
# File 'lib/quicktest.rb', line 51 def self.add_method meth self.methods.push meth end |
.add_singleton_method(meth) ⇒ Object
54 55 56 |
# File 'lib/quicktest.rb', line 54 def self.add_singleton_method meth self.methods.push meth end |