Class: RspecLogFormatter::Analysis::PrettyPrinter
- Inherits:
-
Object
- Object
- RspecLogFormatter::Analysis::PrettyPrinter
- Defined in:
- lib/rspec_log_formatter/analysis/pretty_printer.rb
Instance Method Summary collapse
- #cost_segment(result) ⇒ Object
-
#initialize(results) ⇒ PrettyPrinter
constructor
A new instance of PrettyPrinter.
- #to_s ⇒ Object
Constructor Details
#initialize(results) ⇒ PrettyPrinter
Returns a new instance of PrettyPrinter.
4 5 6 |
# File 'lib/rspec_log_formatter/analysis/pretty_printer.rb', line 4 def initialize(results) @results = results end |
Instance Method Details
#cost_segment(result) ⇒ Object
25 26 27 |
# File 'lib/rspec_log_formatter/analysis/pretty_printer.rb', line 25 def cost_segment(result) " (cost: #{result[:cost].to_i}s)" if result[:cost] end |
#to_s ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rspec_log_formatter/analysis/pretty_printer.rb', line 8 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)}" = result[:failure_messages].map { |fm| " * #{fm}" }.join("\n") title + "\n" + end.join("\n") end |