class MinitestBender::States::Base
Attributes
results[R]
Public Class Methods
new()
click to toggle source
# File lib/minitest-bender/states/base.rb, line 6 def initialize @results = [] end
Public Instance Methods
add_result(result)
click to toggle source
# File lib/minitest-bender/states/base.rb, line 10 def add_result(result) results.push(result) end
color()
click to toggle source
# File lib/minitest-bender/states/base.rb, line 79 def color self.class::COLOR end
colored_icon()
click to toggle source
# File lib/minitest-bender/states/base.rb, line 22 def colored_icon colored(icon) end
colored_icon_with_context_count(result_context, padding_right = 0)
click to toggle source
# File lib/minitest-bender/states/base.rb, line 30 def colored_icon_with_context_count(result_context, padding_right = 0) context_count = results.count { |r| r.context == result_context } with_colored_icon(context_count, padding_right) end
colored_icon_with_count(padding_right = 0)
click to toggle source
# File lib/minitest-bender/states/base.rb, line 26 def colored_icon_with_count(padding_right = 0) with_colored_icon(results.size, padding_right) end
detail_lines(result)
click to toggle source
# File lib/minitest-bender/states/base.rb, line 50 def detail_lines(result) number = "#{result.execution_order})".ljust(4) padding = ' ' * (number.size + 4) time = "(#{result.time_with_unit_and_padding_right.strip})" lines = [] lines << " #{number}#{result.formatted_name_with_context} #{Colorizer.colorize(time, :time)}" lines += inner_detail_lines(result, padding) lines << '' lines << rerun_line(result, padding) lines.compact end
detail_lines_without_header(result)
click to toggle source
# File lib/minitest-bender/states/base.rb, line 64 def detail_lines_without_header(result) number = "#{result.execution_order})".ljust(4) padding = ' ' * (number.size + 2) lines = [] lines += inner_detail_lines(result, padding).tap do |ls| ls[0] = " #{number}#{ls[0].strip}" unless ls.empty? end lines << '' lines << rerun_line(result, padding) lines << '' lines.compact end
formatted_group_label()
click to toggle source
# File lib/minitest-bender/states/base.rb, line 18 def formatted_group_label @formatted_group_label ||= " #{colored(group_label, :bold, :underline)}" end
formatted_label()
click to toggle source
# File lib/minitest-bender/states/base.rb, line 14 def formatted_label @formatted_label ||= colored(label.ljust(7)) end
print_details(io)
click to toggle source
# File lib/minitest-bender/states/base.rb, line 35 def print_details(io) return :no_details if results.empty? sorted_results = results.sort_by(&:source_location) io.puts formatted_group_label io.puts sorted_results.each_with_index do |result, i| detail_lines(result).each { |line| io.puts line } io.puts if i < results.size - 1 end io.puts :printed_details end
test_location(result)
click to toggle source
# File lib/minitest-bender/states/base.rb, line 83 def test_location(result) location(result) end
Private Instance Methods
backtrace(result, padding)
click to toggle source
# File lib/minitest-bender/states/base.rb, line 121 def backtrace(result, padding) "#{padding}#{Colorizer.colorize(location(result), :backtrace)}:" end
colored(string, *args)
click to toggle source
# File lib/minitest-bender/states/base.rb, line 101 def colored(string, *args) Colorizer.colorize(string, color, *args) end
group_label()
click to toggle source
# File lib/minitest-bender/states/base.rb, line 93 def group_label self.class::GROUP_LABEL end
icon()
click to toggle source
# File lib/minitest-bender/states/base.rb, line 97 def icon self.class::ICON end
inner_detail_lines(result, padding)
click to toggle source
# File lib/minitest-bender/states/base.rb, line 109 def inner_detail_lines(result, padding) lines = [] result.failures[0].message.split("\n").each do |line| line.split("\\n").each do |actual_line| adjusted_line = Utils.with_home_shorthand(actual_line) lines << "#{padding}#{colored(adjusted_line)}" end end lines << backtrace(result, padding) lines.compact end
label()
click to toggle source
# File lib/minitest-bender/states/base.rb, line 89 def label self.class::LABEL end
location(result)
click to toggle source
# File lib/minitest-bender/states/base.rb, line 129 def location(result) Utils.relative_path(result.failures[0].location) end
rerun_line(result, padding)
click to toggle source
# File lib/minitest-bender/states/base.rb, line 125 def rerun_line(result, padding) result.rerun_line(padding) end
with_colored_icon(message, padding_right)
click to toggle source
# File lib/minitest-bender/states/base.rb, line 105 def with_colored_icon(message, padding_right) colored("#{icon}#{message}".ljust(padding_right, ' ')) end