Class: Edfize::Tests::Runner

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

Constant Summary collapse

TESTS =
%w( expected_length reserved_area_blank reserved_signal_areas_blank )

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(edf, argv) ⇒ Runner

Returns a new instance of Runner.



8
9
10
11
12
13
14
# File 'lib/edfize/tests/runner.rb', line 8

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.



4
5
6
# File 'lib/edfize/tests/runner.rb', line 4

def edf
  @edf
end

#show_passingObject (readonly)

Returns the value of attribute show_passing.



4
5
6
# File 'lib/edfize/tests/runner.rb', line 4

def show_passing
  @show_passing
end

#tests_failedObject (readonly)

Returns the value of attribute tests_failed.



4
5
6
# File 'lib/edfize/tests/runner.rb', line 4

def tests_failed
  @tests_failed
end

#tests_runObject (readonly)

Returns the value of attribute tests_run.



4
5
6
# File 'lib/edfize/tests/runner.rb', line 4

def tests_run
  @tests_run
end

#verboseObject (readonly)

Returns the value of attribute verbose.



4
5
6
# File 'lib/edfize/tests/runner.rb', line 4

def verbose
  @verbose
end

Instance Method Details



32
33
34
35
36
37
38
39
40
# File 'lib/edfize/tests/runner.rb', line 32

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

#run_testsObject



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

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{|r| r.passes}.count > 0 or @show_passing
  results.each do |result|
    print_result(result)
  end
end