Class: CemAcpt::Bolt::SummaryResults

Inherits:
Utils::FinalizerQueue show all
Defined in:
lib/cem_acpt/bolt/summary_results.rb

Overview

Class that holds the results of the entire Bolt test suite.

Instance Method Summary collapse

Methods inherited from Utils::FinalizerQueue

#finalize!, #finalized?, #initialize, #method_missing, #respond_to_missing?, #to_a

Constructor Details

This class inherits a constructor from CemAcpt::Utils::FinalizerQueue

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CemAcpt::Utils::FinalizerQueue

Instance Method Details

#actionObject



75
76
77
78
# File 'lib/cem_acpt/bolt/summary_results.rb', line 75

def action
  require_finalized(binding)
  map { |rs| rs.results.map(&:action).uniq }.flatten.uniq
end

#errorObject



12
13
14
15
16
17
# File 'lib/cem_acpt/bolt/summary_results.rb', line 12

def error
  require_finalized(binding)
  return unless error?

  @error ||= find { |r| !r.success? }
end

#error?Boolean

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/cem_acpt/bolt/summary_results.rb', line 19

def error?
  require_finalized(binding)
  !success?
end

#failure_countObject



34
35
36
37
# File 'lib/cem_acpt/bolt/summary_results.rb', line 34

def failure_count
  require_finalized(binding)
  @failure_count ||= length - success_count
end

#inspectObject



64
65
66
67
68
# File 'lib/cem_acpt/bolt/summary_results.rb', line 64

def inspect
  return "#<#{self.class}:#{object_id} unfinalized>" unless finalized?

  "#<#{self.class}:#{object_id} #{self}>"
end

#resultsObject



80
81
82
83
# File 'lib/cem_acpt/bolt/summary_results.rb', line 80

def results
  require_finalized(binding)
  @results ||= map(&:results).flatten
end

#results?Boolean

Returns:

  • (Boolean)


85
86
87
88
# File 'lib/cem_acpt/bolt/summary_results.rb', line 85

def results?
  require_finalized(binding)
  !results.empty?
end

#statusObject



39
40
41
42
# File 'lib/cem_acpt/bolt/summary_results.rb', line 39

def status
  require_finalized(binding)
  success? ? 0 : 1
end

#status_strObject



44
45
46
47
# File 'lib/cem_acpt/bolt/summary_results.rb', line 44

def status_str
  require_finalized(binding)
  success? ? 'passed' : 'failed'
end

#success?Boolean

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/cem_acpt/bolt/summary_results.rb', line 24

def success?
  require_finalized(binding)
  @success ||= all?(&:success?)
end

#success_countObject



29
30
31
32
# File 'lib/cem_acpt/bolt/summary_results.rb', line 29

def success_count
  require_finalized(binding)
  @success_count ||= count(&:success?)
end

#summaryObject



49
50
51
52
53
54
55
56
57
# File 'lib/cem_acpt/bolt/summary_results.rb', line 49

def summary
  require_finalized(binding)
  @summary ||= [
    "status: #{status_str}",
    "tests total: #{length}",
    "tests succeeded: #{success_count}",
    "tests failed: #{failure_count}",
  ].join(', ')
end

#summary?Boolean

Returns:

  • (Boolean)


59
60
61
62
# File 'lib/cem_acpt/bolt/summary_results.rb', line 59

def summary?
  require_finalized(binding)
  true
end

#to_hObject



70
71
72
73
# File 'lib/cem_acpt/bolt/summary_results.rb', line 70

def to_h
  require_finalized(binding)
  { 'summary' => summary, 'status' => status, 'results' => map(&:to_h) }
end

#to_sObject



90
91
92
93
# File 'lib/cem_acpt/bolt/summary_results.rb', line 90

def to_s
  require_finalized(binding)
  JSON.pretty_generate(to_h)
end