Class: CemAcpt::TestRunner::RunnerResult
- Inherits:
-
Object
- Object
- CemAcpt::TestRunner::RunnerResult
- Defined in:
- lib/cem_acpt/test_runner/runner_result.rb
Overview
Class to process the results of a Runner
Instance Attribute Summary collapse
-
#run_result ⇒ Object
readonly
Returns the value of attribute run_result.
Instance Method Summary collapse
- #debug? ⇒ Boolean
- #exit_status ⇒ Object
- #from_error(err) ⇒ Object
- #from_json_file(file_path) ⇒ Object
-
#initialize(node, debug: false) ⇒ RunnerResult
constructor
A new instance of RunnerResult.
- #result_array ⇒ Object
- #result_errors? ⇒ Boolean
- #result_failures? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(node, debug: false) ⇒ RunnerResult
Returns a new instance of RunnerResult.
19 20 21 22 23 |
# File 'lib/cem_acpt/test_runner/runner_result.rb', line 19 def initialize(node, debug: false) @node = node @run_result = {} @debug = debug end |
Instance Attribute Details
#run_result ⇒ Object (readonly)
Returns the value of attribute run_result.
17 18 19 |
# File 'lib/cem_acpt/test_runner/runner_result.rb', line 17 def run_result @run_result end |
Instance Method Details
#debug? ⇒ Boolean
29 30 31 |
# File 'lib/cem_acpt/test_runner/runner_result.rb', line 29 def debug? @debug end |
#exit_status ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cem_acpt/test_runner/runner_result.rb', line 33 def exit_status if run_result.nil? 99 elsif run_result.empty? 66 elsif result_errors? || result_failures? 1 else 0 end end |
#from_error(err) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cem_acpt/test_runner/runner_result.rb', line 56 def from_error(err) label = err.class.to_s.start_with?('Errno::') ? 'system_error' : 'standard_error' res = { label => { 'message' => err., 'error_class' => err.class.to_s, 'backtrace' => err.backtrace, 'cause' => err.cause, 'full_message' => err., } } res[label]['errno'] = err.errno if label == 'system_error' new_run_result(res) end |
#from_json_file(file_path) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/cem_acpt/test_runner/runner_result.rb', line 49 def from_json_file(file_path) res = JSON.parse(File.read(file_path)) new_run_result(res) rescue StandardError => e from_error(RspecOutputJSONParserError.new(e)) end |
#result_array ⇒ Object
45 46 47 |
# File 'lib/cem_acpt/test_runner/runner_result.rb', line 45 def result_array [run_result, exit_status] end |
#result_errors? ⇒ Boolean
71 72 73 |
# File 'lib/cem_acpt/test_runner/runner_result.rb', line 71 def result_errors? run_result.keys.any? { |k| k.end_with?('error') } end |
#result_failures? ⇒ Boolean
75 76 77 78 79 80 81 82 |
# File 'lib/cem_acpt/test_runner/runner_result.rb', line 75 def result_failures? if run_result['summary'] run_result['summary']['failure_count'].positive? || run_result['summary']['errors_outside_of_examples_count'].positive? else true end end |
#to_h ⇒ Object
25 26 27 |
# File 'lib/cem_acpt/test_runner/runner_result.rb', line 25 def to_h @run_result end |