Class: OnceoverFormatterParallel

Inherits:
OnceoverFormatter show all
Defined in:
lib/onceover/rspec/formatters.rb

Constant Summary

Constants inherited from OnceoverFormatter

OnceoverFormatter::COMPILATION_ERROR, OnceoverFormatter::ERROR_WITHOUT_LOCATION, OnceoverFormatter::ERROR_WITH_LOCATION

Instance Method Summary collapse

Methods inherited from OnceoverFormatter

#black, #blue, #bold, #calculate_relative_source, #class_name, #cyan, #extract_failure_data, #extract_failures, #green, #initialize, #longest_group, #magenta, #parse_errors, #red, #white, #yellow

Constructor Details

This class inherits a constructor from OnceoverFormatter

Instance Method Details

#dump_failures(notification) ⇒ Object



259
260
261
262
263
264
265
266
267
268
269
# File 'lib/onceover/rspec/formatters.rb', line 259

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) ⇒ Object



249
250
251
252
# File 'lib/onceover/rspec/formatters.rb', line 249

def example_failed notification
  @output << red('F')
  @output.flush
end

#example_group_started(notification) ⇒ Object



240
241
242
# File 'lib/onceover/rspec/formatters.rb', line 240

def example_group_started notification
  # Do nothing
end

#example_passed(notification) ⇒ Object



244
245
246
247
# File 'lib/onceover/rspec/formatters.rb', line 244

def example_passed notification
  @output << green('P')
  @output.flush
end

#example_pending(notification) ⇒ Object



254
255
256
257
# File 'lib/onceover/rspec/formatters.rb', line 254

def example_pending notification
  @output << yellow('?')
  @output.flush
end

#output_results(directory) ⇒ Object



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/onceover/rspec/formatters.rb', line 271

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