Sha256: 0dbadc99dbc8a794687a5e91dd2c6ca696e44be06808bd4bb7d6922a9f350363

Contents?: true

Size: 1.65 KB

Versions: 16

Compression:

Stored size: 1.65 KB

Contents

require 'ansi/code'

module MiniTest
  module Reporters
    # Simple reporter designed for RubyMate.
    class RubyMateReporter
      include Reporter

      INFO_PADDING = 2

      def before_suites(suites, type)
        puts 'Started'
        puts
      end

      def skip(suite, test, test_runner)
        print 'SKIP'
        print_test_with_time(suite, test)
        puts
        puts
      end

      def failure(suite, test, test_runner)
        print 'FAIL'
        print_test_with_time(suite, test)
        puts
        print_info(test_runner.exception, false)
        puts
      end

      def error(suite, test, test_runner)
        print 'ERROR'
        print_test_with_time(suite, test)
        puts
        print_info(test_runner.exception)
        puts
      end

      def after_suites(suites, type)
        total_time = Time.now - runner.suites_start_time

        puts
        puts('Finished in %.5fs' % total_time)
        print('%d tests, %d assertions, ' % [runner.test_count, runner.assertion_count])
        print('%d failures, %d errors, ' % [runner.failures, runner.errors])
        print('%d skips' % runner.skips)
        puts
      end

      private

      def print_test_with_time(suite, test)
        total_time = Time.now - (runner.test_start_time || Time.now)
        print(" #{suite}##{test} (%.2fs)" % total_time)
      end

      def print_info(e, name = true)
        print "#{e.exception.class.to_s}: " if name
        e.message.each_line { |line| puts pad(line) }

        trace = filter_backtrace(e.backtrace)
        trace.each { |line| puts pad(line) }
      end

      def pad(str)
        ' ' * INFO_PADDING + str
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
minitest-reporters-0.14.24 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.14.23 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.14.22 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.14.21 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.14.20 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.14.19 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.14.18 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.14.17 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.14.16 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.14.15 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.14.14 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.14.13 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.14.12 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.14.11 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.14.10 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.14.9 lib/minitest/reporters/ruby_mate_reporter.rb