class OnceoverFormatterParallel

Public Instance Methods

dump_failures(notification) click to toggle source
# File lib/onceover/rspec/formatters.rb, line 260
def dump_failures notification
  # Create a random string
  require 'securerandom'
  random_string = SecureRandom.hex

  # Ensure that the folder exists
  FileUtils.mkdir_p "#{RSpec.configuration.onceover_tempdir}/parallel"

  # Dump the notification to a unique file
  File.write("#{RSpec.configuration.onceover_tempdir}/parallel/results-#{random_string}.yaml", extract_failures(notification).to_yaml)
end
example_failed(notification) click to toggle source
# File lib/onceover/rspec/formatters.rb, line 250
def example_failed notification
  @output << red('F')
  @output.flush
end
example_group_started(notification) click to toggle source
# File lib/onceover/rspec/formatters.rb, line 241
def example_group_started notification
  # Do nothing
end
example_passed(notification) click to toggle source
# File lib/onceover/rspec/formatters.rb, line 245
def example_passed notification
  @output << green('P')
  @output.flush
end
example_pending(notification) click to toggle source
# File lib/onceover/rspec/formatters.rb, line 255
def example_pending notification
  @output << yellow('?')
  @output.flush
end
output_results(directory) click to toggle source
# File lib/onceover/rspec/formatters.rb, line 272
def output_results(directory)
  require 'rspec/core/example'
  # Read all yaml files
  results = {}
  files   = Dir["#{directory}/*.yaml"]

  # Merge data
  roles = files.reduce({}) do |errs, file|
    # Read all files and merge them
    errs.merge(YAML.load_file(file)) {|key, oldval, newval| [oldval, newval].flatten }
  end

  # Delete files from the disk
  files.each { |f| File.delete(f) }

  @output << "\n\n\n"

  # Output errors
  roles.each do |name, errors|
    @output << Onceover::Controlrepo.evaluate_template('error_summary.yaml.erb', binding)
  end
  @output << "\n"
end