class Minitest::Reporters::ProgressReporter

Fuubar-like reporter with a progress bar.

Based upon Jeff Kreefmeijer's Fuubar (MIT License) and paydro's monkey-patch.

@see github.com/jeffkreeftmeijer/fuubar Fuubar @see gist.github.com/356945 paydro's monkey-patch

Constants

PROGRESS_MARK

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method Minitest::Reporters::BaseReporter::new
# File lib/minitest/reporters/progress_reporter.rb, line 18
def initialize(options = {})
  super
  @detailed_skip = options.fetch(:detailed_skip, true)

  @progress = ProgressBar.create(
    total:          total_count,
    starting_at:    count,
    progress_mark:  green(PROGRESS_MARK),
    remainder_mark: ' ',
    format:         options.fetch(:format, '  %C/%c: [%B] %p%% %a, %e'),
    autostart:      false
  )
end

Public Instance Methods

before_test(test) click to toggle source
# File lib/minitest/reporters/progress_reporter.rb, line 41
def before_test(test)
  super
  if options[:verbose]
    puts
    puts("\n%s#%s" % [test_class(test), test.name])
  end
end
record(test) click to toggle source
# File lib/minitest/reporters/progress_reporter.rb, line 49
def record(test)
  super
  return if test.skipped? && !@detailed_skip
  if test.failure
    print "\e[0m\e[1000D\e[K"
    print_colored_status(test)
    print_test_with_time(test)
    puts
    print_info(test.failure, test.error?)
    puts
  end

  if test.skipped? && color != "red"
    self.color = "yellow"
  elsif test.failure
    self.color = "red"
  end

  show
end
report() click to toggle source
# File lib/minitest/reporters/progress_reporter.rb, line 70
def report
  super
  @progress.finish

  puts
  puts('Finished in %.5fs' % total_time)
  print('%d tests, %d assertions, ' % [count, assertions])
  color = failures.zero? && errors.zero? ? :green : :red
  print(send(color) { '%d failures, %d errors, ' } % [failures, errors])
  print(yellow { '%d skips' } % skips)
  puts
end
start() click to toggle source
Calls superclass method
# File lib/minitest/reporters/progress_reporter.rb, line 32
def start
  super
  puts('Started with run options %s' % options[:args])
  puts
  @progress.start
  @progress.total = total_count
  show
end

Private Instance Methods

color() click to toggle source
# File lib/minitest/reporters/progress_reporter.rb, line 94
def color
  @color ||= "green"
end
color=(color) click to toggle source
# File lib/minitest/reporters/progress_reporter.rb, line 98
def color=(color)
  @color = color
  @progress.progress_mark = send(color, PROGRESS_MARK)
end
print_test_with_time(test) click to toggle source
show() click to toggle source
# File lib/minitest/reporters/progress_reporter.rb, line 85
def show
  @progress.increment unless count == 0
end