Class: Edfize::Tests::Runner
- Inherits:
-
Object
- Object
- Edfize::Tests::Runner
- 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
-
#edf ⇒ Object
readonly
Returns the value of attribute edf.
-
#show_passing ⇒ Object
readonly
Returns the value of attribute show_passing.
-
#tests_failed ⇒ Object
readonly
Returns the value of attribute tests_failed.
-
#tests_run ⇒ Object
readonly
Returns the value of attribute tests_run.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize(edf, argv) ⇒ Runner
constructor
A new instance of Runner.
- #print_result(result) ⇒ Object
- #run_tests ⇒ Object
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
#edf ⇒ Object (readonly)
Returns the value of attribute edf.
7 8 9 |
# File 'lib/edfize/tests/runner.rb', line 7 def edf @edf end |
#show_passing ⇒ Object (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_failed ⇒ Object (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_run ⇒ Object (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 |
#verbose ⇒ Object (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
#print_result(result) ⇒ Object
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_tests ⇒ Object
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 |