Class: KnapsackPro::Formatters::RSpecQueueSummaryFormatter

Inherits:
RSpec::Core::Formatters::BaseFormatter
  • Object
show all
Defined in:
lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ RSpecQueueSummaryFormatter

Returns a new instance of RSpecQueueSummaryFormatter.



105
106
107
108
# File 'lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb', line 105

def initialize(output)
  super
  self.class.registered_output = output
end

Class Method Details

.most_recent_failures_summaryObject



33
34
35
36
# File 'lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb', line 33

def self.most_recent_failures_summary
  @most_recent_failures_summary ||= {}
  @most_recent_failures_summary[ENV['KNAPSACK_PRO_QUEUE_ID']] || []
end

.most_recent_failures_summary=(fully_formatted_failed_examples) ⇒ Object



27
28
29
30
31
# File 'lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb', line 27

def self.most_recent_failures_summary=(fully_formatted_failed_examples)
  @most_recent_failures_summary = {
    ENV['KNAPSACK_PRO_QUEUE_ID'] => fully_formatted_failed_examples
  }
end

.most_recent_pendingObject



44
45
46
47
# File 'lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb', line 44

def self.most_recent_pending
  @most_recent_pending ||= {}
  @most_recent_pending[ENV['KNAPSACK_PRO_QUEUE_ID']] || []
end

.most_recent_pending=(fully_formatted_pending_examples) ⇒ Object



38
39
40
41
42
# File 'lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb', line 38

def self.most_recent_pending=(fully_formatted_pending_examples)
  @most_recent_pending = {
    ENV['KNAPSACK_PRO_QUEUE_ID'] => fully_formatted_pending_examples
  }
end

.most_recent_summaryObject



55
56
57
58
# File 'lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb', line 55

def self.most_recent_summary
  @most_recent_summary ||= {}
  @most_recent_summary[ENV['KNAPSACK_PRO_QUEUE_ID']] || []
end

.most_recent_summary=(fully_formatted) ⇒ Object



49
50
51
52
53
# File 'lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb', line 49

def self.most_recent_summary=(fully_formatted)
  @most_recent_summary = {
    ENV['KNAPSACK_PRO_QUEUE_ID'] => fully_formatted
  }
end


79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb', line 79

def self.print_exit_summary
  registered_output.puts('Knapsack Pro Queue exited/aborted!')
  registered_output.puts('')

  unexecuted_test_files = KnapsackPro.tracker.unexecuted_test_files
  unless unexecuted_test_files.empty?
    registered_output.puts('Unexecuted tests on this CI node:')
    registered_output.puts(unexecuted_test_files)
    registered_output.puts('')
  end

  unless most_recent_pending.empty?
    registered_output.puts('All pending tests on this CI node:')
    registered_output.puts(most_recent_pending)
    registered_output.puts('')
  end

  unless most_recent_failures_summary.empty?
    registered_output.puts('All failed tests on this CI node:')
    registered_output.puts(most_recent_failures_summary)
    registered_output.puts('')
  end

  registered_output.puts(most_recent_summary)
end


60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb', line 60

def self.print_summary
  registered_output.puts('Knapsack Pro Queue finished!')
  registered_output.puts('')

  unless most_recent_pending.empty?
    registered_output.puts('All pending tests on this CI node:')
    registered_output.puts(most_recent_pending)
    registered_output.puts('')
  end

  unless most_recent_failures_summary.empty?
    registered_output.puts('All failed tests on this CI node:')
    registered_output.puts(most_recent_failures_summary)
    registered_output.puts('')
  end

  registered_output.puts(most_recent_summary)
end

.registered_outputObject



23
24
25
# File 'lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb', line 23

def self.registered_output
  @registered_output[ENV['KNAPSACK_PRO_QUEUE_ID']]
end

.registered_output=(output) ⇒ Object



17
18
19
20
21
# File 'lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb', line 17

def self.registered_output=(output)
  @registered_output = {
    ENV['KNAPSACK_PRO_QUEUE_ID'] => output
  }
end

Instance Method Details

#dump_failures(notification) ⇒ Object



110
111
112
113
# File 'lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb', line 110

def dump_failures(notification)
  return if notification.failure_notifications.empty?
  self.class.most_recent_failures_summary = notification.fully_formatted_failed_examples
end

#dump_pending(notification) ⇒ Object



115
116
117
118
# File 'lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb', line 115

def dump_pending(notification)
  return if notification.pending_examples.empty?
  self.class.most_recent_pending = notification.fully_formatted_pending_examples
end

#dump_summary(summary) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb', line 120

def dump_summary(summary)
  colorizer = ::RSpec::Core::Formatters::ConsoleCodes
  duration = KnapsackPro.tracker.global_time_since_beginning
  formatted_duration = ::RSpec::Core::Formatters::Helpers.format_duration(duration)

  formatted = "\nFinished in #{formatted_duration}\n" \
    "#{summary.colorized_totals_line(colorizer)}\n"

  unless summary.failed_examples.empty?
    formatted += (summary.colorized_rerun_commands(colorizer) + "\n")
  end

  self.class.most_recent_summary = formatted
end