Class: RSpec::FlakeClassifier::JUnitFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/flake/classifier/formatter.rb,
sig/rspec/flake/classifier.rbs

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ JUnitFormatter

Returns a new instance of JUnitFormatter.

Parameters:

  • output (Object)


105
106
107
108
# File 'lib/rspec/flake/classifier/formatter.rb', line 105

def initialize(output)
  @output = output
  @testcases = []
end

Instance Method Details

#dump_summary(_notification) ⇒ void

This method returns an undefined value.

Parameters:

  • notification (Object)


127
128
129
130
131
132
# File 'lib/rspec/flake/classifier/formatter.rb', line 127

def dump_summary(_notification)
  output.puts(%(<?xml version="1.0" encoding="UTF-8"?>))
  output.puts(%(<testsuite tests="#{testcases.length}">))
  testcases.each { |attributes| output.puts(render_case(attributes)) }
  output.puts("</testsuite>")
end

#example_failed(notification) ⇒ void

This method returns an undefined value.

Parameters:

  • notification (Object)


114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/rspec/flake/classifier/formatter.rb', line 114

def example_failed(notification)
  example = notification.example
  exception = notification.respond_to?(:exception) ? notification.exception : example.exception
  signature = Signature.from_exception(exception)
  classification = classify(example, exception)
  @testcases << testcase(
    example,
    failure: exception.message,
    signature: signature.digest,
    classification: classification
  )
end

#example_passed(notification) ⇒ void

This method returns an undefined value.

Parameters:

  • notification (Object)


110
111
112
# File 'lib/rspec/flake/classifier/formatter.rb', line 110

def example_passed(notification)
  @testcases << testcase(notification.example)
end