class Minitest::Heat::Issue
Wrapper for Result to provide a more natural-language approach to result details
Constants
- MARKERS
- SHARED_SYMBOLS
- SLOW_THRESHOLDS
Attributes
failure[R]
location[R]
result[R]
Public Class Methods
new(result)
click to toggle source
# File lib/minitest/heat/issue.rb, line 36 def initialize(result) @result = result @failure = result.failures.any? ? result.failures.first : nil @location = Location.new(result.source_location, @failure&.backtrace) end
Public Instance Methods
arrow()
click to toggle source
# File lib/minitest/heat/issue.rb, line 59 def arrow SHARED_SYMBOLS[:arrow] end
exception()
click to toggle source
# File lib/minitest/heat/issue.rb, line 113 def exception failure.exception end
freshest_file()
click to toggle source
# File lib/minitest/heat/issue.rb, line 148 def freshest_file backtrace.recently_modified.first end
hit?()
click to toggle source
# File lib/minitest/heat/issue.rb, line 81 def hit? !passed? || slow? end
in_source?()
click to toggle source
# File lib/minitest/heat/issue.rb, line 97 def in_source? location.proper_failure? end
in_test?()
click to toggle source
# File lib/minitest/heat/issue.rb, line 93 def in_test? location.broken_test? end
label()
click to toggle source
# File lib/minitest/heat/issue.rb, line 125 def label if error? && in_test? # When the exception came out of the test itself, that's a different kind of exception # that really only indicates there's a problem with the code in the test. It's kind of # between an error and a test. 'Test Error' elsif error? || !passed? failure.result_label elsif slow? 'Passed but Slow' else end end
marker()
click to toggle source
# File lib/minitest/heat/issue.rb, line 140 def marker MARKERS.fetch(type.to_sym) end
painful?()
click to toggle source
# File lib/minitest/heat/issue.rb, line 89 def painful? time >= SLOW_THRESHOLDS[:painful] end
short_location()
click to toggle source
# File lib/minitest/heat/issue.rb, line 43 def short_location location.to_s.delete_prefix(Dir.pwd) end
slow?()
click to toggle source
# File lib/minitest/heat/issue.rb, line 85 def slow? time >= SLOW_THRESHOLDS[:slow] end
slowness()
click to toggle source
# File lib/minitest/heat/issue.rb, line 121 def slowness "#{time.round(2)}s" end
spacer()
click to toggle source
# File lib/minitest/heat/issue.rb, line 55 def spacer SHARED_SYMBOLS[:spacer] end
summary()
click to toggle source
# File lib/minitest/heat/issue.rb, line 144 def summary error? ? exception_parts[0] : exception.message end
test_class()
click to toggle source
# File lib/minitest/heat/issue.rb, line 101 def test_class result.klass end
test_identifier()
click to toggle source
# File lib/minitest/heat/issue.rb, line 105 def test_identifier result.name end
test_name()
click to toggle source
# File lib/minitest/heat/issue.rb, line 109 def test_name test_identifier.delete_prefix('test_').gsub('_', ' ').capitalize end
time()
click to toggle source
# File lib/minitest/heat/issue.rb, line 117 def time result.time end
to_hit()
click to toggle source
# File lib/minitest/heat/issue.rb, line 47 def to_hit [ location.project_file.to_s, location.project_failure_line, type ] end
type()
click to toggle source
# File lib/minitest/heat/issue.rb, line 63 def type # rubocop:disable Metrics/MethodLength if error? && in_test? :broken elsif error? :error elsif skipped? :skipped elsif !passed? :failure elsif painful? :painful elsif slow? :slow else :success end end
Private Instance Methods
exception_parts()
click to toggle source
# File lib/minitest/heat/issue.rb, line 154 def exception_parts exception.message.split("\n") end