123456789_123456789_123456789_123456789_123456789_

Class: RuboCop::RSpec::ParallelFormatter

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, RSpec::Core::Formatters::BaseTextFormatter
Instance Chain:
self, RSpec::Core::Formatters::BaseTextFormatter
Inherits: RSpec::Core::Formatters::BaseTextFormatter
  • Object
Defined in: lib/rubocop/rspec/parallel_formatter.rb

Overview

RSpec formatter for use with running rake spec in parallel. This formatter removes much of the noise from RSpec so that only the important information will be surfaced by test-queue. It also adds metadata to the output in order to more easily find the text needed for outputting after the parallel run completes.

Instance Method Summary

Instance Method Details

#colorize_summary(summary) (private)

[ GitHub ]

  
# File 'lib/rubocop/rspec/parallel_formatter.rb', line 53

def colorize_summary(summary)
  totals = totals(summary)

  if summary.failure_count.positive? || summary.errors_outside_of_examples_count.positive?
    colorizer.wrap(totals, ::RSpec.configuration.failure_color)
  else
    colorizer.wrap(totals, ::RSpec.configuration.success_color)
  end
end

#colorizer (private)

[ GitHub ]

  
# File 'lib/rubocop/rspec/parallel_formatter.rb', line 40

def colorizer
  @colorizer ||= ::RSpec::Core::Formatters::ConsoleCodes
end

#dump_failures(notification)

The BEGIN/END comments are used by spec_runner.rake to determine what output goes where in the final parallelized output, and should not be removed!

[ GitHub ]

  
# File 'lib/rubocop/rspec/parallel_formatter.rb', line 22

def dump_failures(notification)
  return if notification.failure_notifications.empty?

  output.puts '# FAILURES BEGIN'
  notification.failure_notifications.each do |failure|
    output.puts failure.fully_formatted('*', colorizer)
  end
  output.puts
  output.puts '# FAILURES END'
end

#dump_pending

Don’t show pending tests

[ GitHub ]

  
# File 'lib/rubocop/rspec/parallel_formatter.rb', line 17

def dump_pending(*); end

#dump_summary(summary)

[ GitHub ]

  
# File 'lib/rubocop/rspec/parallel_formatter.rb', line 33

def dump_summary(summary)
  output_summary(summary)
  output_rerun_commands(summary)
end

#output_rerun_commands(summary) (private)

The BEGIN/END comments are used by spec_runner.rake to determine what output goes where in the final parallelized output, and should not be removed!

[ GitHub ]

  
# File 'lib/rubocop/rspec/parallel_formatter.rb', line 66

def output_rerun_commands(summary)
  output.puts '# RERUN BEGIN'
  output.puts summary.colorized_rerun_commands.lines[3..].join
  output.puts '# RERUN END'
end

#output_summary(summary) (private)

The BEGIN/END comments are used by spec_runner.rake to determine what output goes where in the final parallelized output, and should not be removed!

[ GitHub ]

  
# File 'lib/rubocop/rspec/parallel_formatter.rb', line 47

def output_summary(summary)
  output.puts '# SUMMARY BEGIN'
  output.puts colorize_summary(summary)
  output.puts '# SUMMARY END'
end

#pluralize(*args) (private)

[ GitHub ]

  
# File 'lib/rubocop/rspec/parallel_formatter.rb', line 85

def pluralize(*args)
  ::RSpec::Core::Formatters::Helpers.pluralize(*args)
end

#totals(summary) (private)

[ GitHub ]

  
# File 'lib/rubocop/rspec/parallel_formatter.rb', line 72

def totals(summary)
  output = pluralize(summary.example_count, 'example')
  output += ", #{summary.pending_count} pending" if summary.pending_count.positive?
  output += ", #{pluralize(summary.failure_count, 'failure')}"

  if summary.errors_outside_of_examples_count.positive?
    error_count = pluralize(summary.errors_outside_of_examples_count, 'error')
    output += ", #{error_count} occurred outside of examples"
  end

  output
end