Sha256: 44d1709b0c154e7e404988631c06882061ecfc9fa833853c8cc9dfb1b139a6af

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

module Minitest
  class << self
    def plugin_minitest_reporter_init(options)
      if defined?(Minitest::Reporters) && Minitest::Reporters.reporters
        reporter.reporters = Minitest::Reporters.reporters + guard_reporter
        reporter.reporters.each do |reporter|
          reporter.io = options[:io]
          reporter.add_defaults(options.merge(:total_count => total_count(options))) if reporter.respond_to? :add_defaults
        end
      end
    end

    private

    # stolen from minitest self.run
    def total_count(options)
      filter = options[:filter] || '/./'
      filter = Regexp.new $1 if filter =~ /\/(.*)\//

      Minitest::Runnable.runnables.map(&:runnable_methods).flatten.find_all { |m|
        filter === m || filter === "#{self}##{m}"
      }.size
    end

    def guard_reporter
      guards = Array(reporter.reporters.detect { |r| r.class.name == "Guard::Minitest::Reporter" })
      return guards unless ENV['RM_INFO']

      warn 'RM_INFO is set thus guard reporter has been dropped' if guards.empty?
      []
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
minitest-reporters-1.0.14 lib/minitest/minitest_reporter_plugin.rb
minitest-reporters-1.0.13 lib/minitest/minitest_reporter_plugin.rb
minitest-reporters-1.0.12 lib/minitest/minitest_reporter_plugin.rb