Module: TestProf::FactoryProf::Printers::Simple

Extended by:
Logging
Defined in:
lib/test_prof/factory_prof/printers/simple.rb

Overview

:nodoc: all

Constant Summary

Constants included from Logging

Logging::COLORS

Class Method Summary collapse

Methods included from Logging

build_log_msg, colorize, log

Class Method Details

.dump(result) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/test_prof/factory_prof/printers/simple.rb', line 9

def dump(result)
  return log(:info, "No factories detected") if result.raw_stats == {}
  msgs = []

  total = result.stats.sum { |stat| stat[:total] }
  total_top_level = result.stats.sum { |stat| stat[:top_level] }
  total_uniq_factories = result.stats.map { |stat| stat[:name] }.uniq.count

  msgs <<
    <<~MSG
      Factories usage

       Total: #{total}
       Total top-level: #{total_top_level}
       Total uniq factories: #{total_uniq_factories}

       total      top-level                            name
    MSG

  result.stats.each do |stat|
    msgs << format("%6d    %11d  %30s", stat[:total], stat[:top_level], stat[:name])
  end

  log :info, msgs.join("\n")
end