Class: Edfize::Tests::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/edfize/tests/runner.rb

Overview

Runs a series of tests on an EDF

Constant Summary collapse

TESTS =
%w(expected_length reserved_area_blank reserved_signal_areas_blank valid_date)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(edf, argv) ⇒ Runner

Returns a new instance of Runner.



11
12
13
14
15
16
17
# File 'lib/edfize/tests/runner.rb', line 11

def initialize(edf, argv)
  @tests_run = 0
  @tests_failed = 0
  @edf = edf
  @verbose = argv.include?('--quiet') ? false : true
  @show_passing = argv.include?('--failing') ? false : true
end

Instance Attribute Details

#edfObject (readonly)

Returns the value of attribute edf.



7
8
9
# File 'lib/edfize/tests/runner.rb', line 7

def edf
  @edf
end

#show_passingObject (readonly)

Returns the value of attribute show_passing.



7
8
9
# File 'lib/edfize/tests/runner.rb', line 7

def show_passing
  @show_passing
end

#tests_failedObject (readonly)

Returns the value of attribute tests_failed.



7
8
9
# File 'lib/edfize/tests/runner.rb', line 7

def tests_failed
  @tests_failed
end

#tests_runObject (readonly)

Returns the value of attribute tests_run.



7
8
9
# File 'lib/edfize/tests/runner.rb', line 7

def tests_run
  @tests_run
end

#verboseObject (readonly)

Returns the value of attribute verbose.



7
8
9
# File 'lib/edfize/tests/runner.rb', line 7

def verbose
  @verbose
end

Instance Method Details



35
36
37
38
39
40
41
42
43
# File 'lib/edfize/tests/runner.rb', line 35

def print_result(result)
  if show_passing || !result.passes
    puts result.pass_fail
    unless result.passes || !verbose
      puts result.expected
      puts result.actual
    end
  end
end

#run_testsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/edfize/tests/runner.rb', line 19

def run_tests
  results = []

  TESTS.each do |test_name|
    result = Edfize::Tests.send("test_#{test_name}", self)
    @tests_failed += 1 unless result.passes
    @tests_run += 1
    results << result
  end

  puts "\n#{@edf.filename}" if results.reject(&:passes).count > 0 || @show_passing
  results.each do |result|
    print_result(result)
  end
end