Sha256: 58e18250e230fab118f8797426a92decc89242970747a04b47b6c1b9e2d9019b

Contents?: true

Size: 1.56 KB

Versions: 6

Compression:

Stored size: 1.56 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)
        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
        print(" #{suite}##{test} (%.2fs)" % total_time)
      end

      def print_info(e)
        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

6 entries across 6 versions & 1 rubygems

Version Path
minitest-reporters-0.14.0 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.13.1 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.13.0 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.12.2 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.12.1 lib/minitest/reporters/ruby_mate_reporter.rb
minitest-reporters-0.12.0 lib/minitest/reporters/ruby_mate_reporter.rb