class Minitest::SnailReporter

Attributes

max_duration[R]
slow_tests[R]

Public Class Methods

enable!(options = {}) click to toggle source
# File lib/minitest/snail_reporter.rb, line 11
def self.enable!(options = {})
  @enabled = true
  self.options.merge!(options)
end
enabled?() click to toggle source
# File lib/minitest/snail_reporter.rb, line 16
def self.enabled?
  @enabled ||= false
end
new(io = STDOUT, options = self.class.options) click to toggle source
Calls superclass method
# File lib/minitest/snail_reporter.rb, line 20
def initialize(io = STDOUT, options = self.class.options)
  super
  
  @max_duration = options.fetch(:max_duration)
  @slow_tests = []
end
options() click to toggle source
# File lib/minitest/snail_reporter.rb, line 5
def self.options
  @default_options ||= {
    :max_duration => 2
  }
end

Public Instance Methods

record(result) click to toggle source
# File lib/minitest/snail_reporter.rb, line 27
def record result
  slow_tests << result if result.time > max_duration
end
report() click to toggle source
# File lib/minitest/snail_reporter.rb, line 31
def report
  return if slow_tests.empty?
  
  slow_tests.sort_by!{|r| -r.time}
  
  io.puts
  io.puts "#{slow_tests.length} slow tests."
  slow_tests.each_with_index do |result, i|
    io.puts "%3d) %s: %.2f s" % [i+1, result.location, result.time]
  end
end