Class: MicroTest::TestMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/microtest.rb

Overview

Encapsualtes test method for execution by RubyTest. Mainly this separate encapsulation allows the test description to be something other than just the method name, e.g. if the ‘MicroTest.natural_names` flag is set to true.

Instance Method Summary collapse

Constructor Details

#initialize(testcase, method) ⇒ TestMethod

Returns a new instance of TestMethod.



89
90
91
92
# File 'lib/microtest.rb', line 89

def initialize(testcase, method)
  @testcase = testcase
  @method   = method
end

Instance Method Details

#callObject



94
95
96
97
98
# File 'lib/microtest.rb', line 94

def call
  @testcase.setup
  @method.call
  @testcase.teardown
end

#to_sObject



100
101
102
103
104
# File 'lib/microtest.rb', line 100

def to_s
  name = @method.name.to_s  
  name.gsub!('_', ' ') if MicroTest.natural_names
  return name
end