Sha256: 2ce32efd928371f26bc75fa50b8431e5a873e79a83557fa83c05e38f7211a12a

Contents?: true

Size: 824 Bytes

Versions: 1

Compression:

Stored size: 824 Bytes

Contents

require "minitest/blink1_reporter/class"
require "blink1"

module Minitest
  class Blink1Reporter
    SUCCESS = [0, 170, 0]
    SKIPPED = [180, 150, 0]
    FAILURE = [180, 0, 0]
    RUNNING = [170, 0, 180]
    FADE = 150

    def initialize(_options)
      @results = []
    end

    def record(result)
      blink1.fade_to_rgb(FADE, *RUNNING)
      @results << result
    end

    def report
      if @results.any?(&:skipped?)
        blink1.fade_to_rgb(FADE, *SKIPPED)
      elsif !@results.all?(&:passed?)
        blink1.fade_to_rgb(FADE, *FAILURE)
      else
        blink1.fade_to_rgb(FADE, *SUCCESS)
      end

      blink1.close
    end

    private

    def blink1
      @blink1 ||= ::Blink1.new.tap(&:open)
    end
  end

  def self.plugin_blink1_init(options)
    reporter << Blink1Reporter.new(options)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
minitest-blink1_reporter-0.1.0 lib/minitest/blink1_reporter_plugin.rb