Sha256: 7feabeb94514fb741d523726cbe2b670b452dd986e8a2df10bd5e00a617655bd
Contents?: true
Size: 972 Bytes
Versions: 1
Compression:
Stored size: 972 Bytes
Contents
# frozen_string_literal: true module Undercover class Formatter def initialize(results) @results = results end def to_s return success unless @results.any? ([warnings_header] + formatted_warnings).join("\n") end private def formatted_warnings @results.map.with_index(1) do |res, idx| "🚨 #{idx}) node `#{res.node.name}` type: #{res.node.class},\n" + (' ' * pad_size) + "loc: #{res.file_path_with_lines}," \ " coverage: #{res.coverage_f * 100}%\n" + res.pretty_print end end def success "#{Rainbow('undercover').bold.green}: ✅ No coverage" \ ' is missing in latest changes' end def warnings_header "#{Rainbow('undercover').bold.red}: " \ '👮♂️ some methods have no test coverage! Please add specs for' \ ' methods listed below' end def pad_size 5 + (@results.size - 1).to_s.length end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
undercover-0.1.0 | lib/undercover/formatter.rb |