Class: Most::TestCase

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

Instance Method Summary collapse

Methods included from RunnerHelpers

#create_test_runner

Methods included from OptionsHelpers

#create_options

Methods included from PathHelpers

#path

Methods included from MetaProgrammable

#method_missing

Constructor Details

#initialize(name = 'Anonymous Test Case', input = '', output = '', output_destination = nil, output_preprocessor = lambda { |data| data.to_s().strip() }, runner = TestRunner.new(), &block) ⇒ TestCase



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/most/structures/test_case.rb', line 43

def initialize(name   = 'Anonymous Test Case',
               input  = '',
               output = '',
               output_destination  = nil,
               output_preprocessor = lambda { |data| data.to_s().strip() },
               runner = TestRunner.new(),
               &block)

  @name   = name
  @input  = input

  @output = output
  @output_destination  = output_destination
  @output_preprocessor = output_preprocessor

  @runner = runner

  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

#run(options, entities) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/most/structures/test_case.rb', line 63

def run(options, entities)
  SERVICES[:environment].state("#{2.w}Processing test case: #{@name}")

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

  if options[:tests/:report/:specs]
    result.specs = {:name => @name,
                    :correct_output => @output,
                    :output_destination => @output_destination,
                    :runner => @runner}
  end

  result << process(options, entities)

  correct_status = result.last.last[:correct]; correct_status ||= false
  message = "#{2.w}|--> Test case '#{@name}' correct?: #{correct_status}"

  SERVICES[:environment].show_message(message)

  result
end