Sha256: dc25dcea627f9958bb08f66a2c0ded12618b972cf13b58536d12111ab189010b

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require "minitest/retry/version"

module Minitest
  module Retry
    def self.use!(retry_count: 3, io: $stdout, verbose: true)
      @retry_count, @io, @verbose = retry_count, io, verbose
      Minitest.prepend(self)
    end

    def self.retry_count
      @retry_count
    end

    def self.io
      @io
    end

    def self.verbose
      @verbose
    end

    module ClassMethods
      def run_one_method(klass, method_name)
        retry_count = Minitest::Retry.retry_count
        result = super(klass, method_name)
        if !result.failures.empty? && !result.skipped?
          retry_count.times do |count|
            if Minitest::Retry.verbose && Minitest::Retry.io
              msg = "[MiniestRetry] retry '%s' count: %s,  msg: %s\n" %
                [method_name, count + 1, result.failures.join(",")]
              Minitest::Retry.io.puts(msg)
            end

            result = super(klass, method_name)
            break if result.failures.empty?
          end
        end
        result
      end
    end

    def self.prepended(base)
      class << base
        prepend ClassMethods
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
minitest-retry-0.1.3 lib/minitest/retry.rb