Class: Minitest::Reporters::FailureFormatter

Inherits:
SimpleDelegator
  • Object
show all
Includes:
ANSI::Code
Defined in:
lib/minitest/reporters/failure_formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(test) ⇒ FailureFormatter

Returns a new instance of FailureFormatter.



8
9
10
11
# File 'lib/minitest/reporters/failure_formatter.rb', line 8

def initialize(test)
  @test = test
  super
end

Instance Method Details

#to_h ⇒ Object



21
22
23
24
25
26
27
# File 'lib/minitest/reporters/failure_formatter.rb', line 21

def to_h
  {
    test_and_module_name: "#{test.klass}##{test.name}",
    test_name: test.name,
    output: to_s,
  }
end

#to_s ⇒ Object



13
14
15
16
17
18
19
# File 'lib/minitest/reporters/failure_formatter.rb', line 13

def to_s
  [
    header,
    body,
    "\n"
  ].flatten.compact.join("\n")
end