Sha256: 7170338f216f166c86907af88e38591386c427aaaad04dcbaa31fab4bfae16f9

Contents?: true

Size: 730 Bytes

Versions: 2

Compression:

Stored size: 730 Bytes

Contents

require "minitest"
require "minitest/warning/version"
require "minitest/warning/reporter"

module Minitest
  module Warning
    class << self
      attr_reader :warnings

      def enable!(path: nil)
        @enable= true
        @warnings = []
        @path = path
      end

      def enable?
        defined?(@enable) && @enable
      end

      def disable!
        @enable = false
      end

      def add_warning(message)
        if @path
          return unless message.match?(@path)
        end

        @warnings << message
      end

      def has_warning?
        !@warnings.empty?
      end
    end
  end
end

def Warning.warn(message)
  Minitest::Warning.add_warning(message) if Minitest::Warning.enable?
  super
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
minitest-warning-0.1.1 lib/minitest/warning.rb
minitest-warning-0.1.0 lib/minitest/warning.rb