Class: QuickTest::TestRunner

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tested) ⇒ TestRunner

Returns a new instance of TestRunner.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/quicktest.rb', line 55

def initialize tested
  self.class.tested_self = tested

  q = tested.method(:quicktest)
  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 method"
  end

  tested.send :__quicktest_run_tests__
end

Class Attribute Details

.methodsObject

Returns the value of attribute methods.



43
44
45
# File 'lib/quicktest.rb', line 43

def methods
  @methods
end

.tested_selfObject

Returns the value of attribute tested_self.



43
44
45
# File 'lib/quicktest.rb', line 43

def tested_self
  @tested_self
end

Class Method Details

.add_method(meth) ⇒ Object



48
49
50
# File 'lib/quicktest.rb', line 48

def self.add_method( meth )
  self.methods.push meth
end

.add_singleton_method(meth) ⇒ Object



51
52
53
# File 'lib/quicktest.rb', line 51

def self.add_singleton_method( meth )
  self.methods.push meth
end