Class: Most::TestRunner

Inherits:
Object show all
Includes:
MetaProgrammable, OptionsHelpers, PathHelpers
Defined in:
lib/most/structures/test_runner.rb

Instance Method Summary collapse

Methods included from OptionsHelpers

#create_options

Methods included from PathHelpers

#path

Methods included from MetaProgrammable

#method_missing

Constructor Details

#initialize(name = 'Anonymous Test Runner', steps = [], &block) ⇒ TestRunner

Returns a new instance of TestRunner.



41
42
43
44
45
46
# File 'lib/most/structures/test_runner.rb', line 41

def initialize(name = 'Anonymous Test Runner', steps = [], &block)
  @name  = name
  @steps = steps

  instance_eval(&block) if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class MetaProgrammable

Instance Method Details

#add_step(step, &block) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/most/structures/test_runner.rb', line 66

def add_step(step, &block)
  @steps ||= []
  if step.is_a?(Class) and block_given?
    @steps << step.new(&block)
  else
    @steps << step
  end
end

#run(options, entities, input) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/most/structures/test_runner.rb', line 48

def run(options, entities, input)
  SERVICES[:environment].state("#{4.w}Processing test runner #{@name}")
  SERVICES[:environment].state("#{4.w}Number of steps: #{@steps.size}")

  result = Report.new("Test Runner: #{@name}")

  if options[:tests/:report/:specs]
    result.specs = {:name  => @name,
                    :steps => @steps}
  end

  result << execute(options, entities, input)
  
  SERVICES[:environment].state("#{4.w}|--> Test run successful?: #{result.last[:success]}")

  result
end