Class: Minitest::FailureReporter::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/failure_reporter_reporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(io, options) ⇒ Reporter

Returns a new instance of Reporter.



7
8
9
10
11
# File 'lib/minitest/failure_reporter_reporter.rb', line 7

def initialize(io, options)
  @io = io
  @results = []
  @options = options
end

Instance Method Details

#format(test) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/minitest/failure_reporter_reporter.rb', line 30

def format(test)
  test_file, test_line = test.source_location
  {
    test_file_path: normalize_file_path(test_file),
    test_line: test_line,
    test_id: "#{test.klass}##{test.name}",
    test_name: test.name,
    test_suite: test.klass,
    error_class: test.failure.exception.class.name,
    error_message: full_error_message(test),
    output: full_error_message(test),
  }
end

#passed?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/minitest/failure_reporter_reporter.rb', line 13

def passed?
  true
end

#record(result) ⇒ Object



19
20
21
22
23
# File 'lib/minitest/failure_reporter_reporter.rb', line 19

def record(result)
  if has_failures?(result)
    @results << result
  end
end

#reportObject



25
26
27
28
# File 'lib/minitest/failure_reporter_reporter.rb', line 25

def report
  failures = @results.map { |test| format(test) }.to_json
  @io.puts(failures)
end

#startObject



17
# File 'lib/minitest/failure_reporter_reporter.rb', line 17

def start; end