Class: RspecLogfmtFormatter

Inherits:
RSpec::Core::Formatters::BaseFormatter
  • Object
show all
Defined in:
lib/rspec_logfmt_formatter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRspecLogfmtFormatter

Returns a new instance of RspecLogfmtFormatter.



17
18
19
20
# File 'lib/rspec_logfmt_formatter.rb', line 17

def initialize(...)
  super
  @retries = []
end

Class Method Details

.collate(input) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/rspec_logfmt_formatter.rb', line 7

def self.collate(input)
  collated = {}

  input.scan(/(tests\.\w+)="(\d+)"/) do |key, value|
    collated[key] = collated[key].to_i + value.to_i
  end

  collated.map { |key, value| "#{key}=\"#{value}\"" }.join("\n")
end

Instance Method Details

#dump_summary(notification) ⇒ Object



22
23
24
25
# File 'lib/rspec_logfmt_formatter.rb', line 22

def dump_summary(notification)
  @summary = notification
  logfmt_dump
end

#retry(example) ⇒ Object



27
28
29
# File 'lib/rspec_logfmt_formatter.rb', line 27

def retry(example)
  @retries << example
end