Created
October 8, 2014 00:08
-
-
Save sfcgeorge/657bd93c38344334b52c to your computer and use it in GitHub Desktop.
Blink(1) Minitest Reporter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'blink1' | |
require 'minitest/reporters' | |
module Minitest | |
module Reporters | |
class Blink1Reporter < BaseReporter | |
SUCCESS = [0, 170, 0] | |
SKIPPED = [180, 150, 0] | |
FAILURE = [180, 0, 0] | |
FADE = 150 | |
def record(test) | |
super | |
if test.passed? | |
blink1.fade_to_rgb(FADE, *SUCCESS) | |
elsif test.skipped? | |
blink1.fade_to_rgb(FADE, *SKIPPED) | |
elsif test.failure | |
blink1.fade_to_rgb(FADE, *FAILURE) | |
end | |
end | |
def report | |
super | |
if failures > 0 || errors > 0 | |
blink1.fade_to_rgb(FADE, *FAILURE) | |
elsif skips > 0 | |
blink1.fade_to_rgb(FADE, *SKIPPED) | |
else | |
blink1.fade_to_rgb(FADE, *SUCCESS) | |
end | |
blink1.close | |
end | |
private | |
def blink1 | |
@blink1 ||= ::Blink1.new.tap(&:open) | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group :test do | |
gem 'minitest-reporters' | |
gem 'rb-blink1' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Minitest::Reporters.use!( | |
[ | |
Minitest::Reporters::DefaultReporter.new, | |
Minitest::Reporters::Blink1Reporter.new | |
], | |
ENV, | |
Minitest.backtrace_filter | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment