Sha256: 718ffdce17bb8ff88f6d57ad0d53905a259167c16a72998d579ef456a13ee1d8

Contents?: true

Size: 869 Bytes

Versions: 2

Compression:

Stored size: 869 Bytes

Contents

module RspecLogFormatter
  module Analysis
    class PrettyPrinter
      def initialize(results)
        @results = results
      end

      def to_s
        results = @results.reject do |result|
          result[:fraction] == 0.0
        end.first(10)

        header = if results.empty?
          "None of the specs were flaky"
        else
          "Top #{results.size} flakiest examples\n"
        end
        header + results.each_with_index.map do |result, i|
          title = "  #{i+1}) #{result[:description]} -- #{(100.0*result[:fraction]).to_i}%#{cost_segment(result)}"
          failure_messages = result[:failure_messages].map { |fm| "    * #{fm}" }.join("\n")
          title + "\n" + failure_messages
        end.join("\n")
      end

      def cost_segment(result)
        " (cost: #{result[:cost].to_i}s)" if result[:cost]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec_log_formatter-0.2.1 lib/rspec_log_formatter/analysis/pretty_printer.rb
rspec_log_formatter-0.2.0 lib/rspec_log_formatter/analysis/pretty_printer.rb