Created
December 17, 2014 15:21
-
-
Save pacojp/0ec37d85bc32d6d3eec1 to your computer and use it in GitHub Desktop.
miintest5でterminal-notifierを使うサンプル
This file contains hidden or 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
# https://github.com/alloy/terminal-notifier | |
# | |
# via. | |
# https://github.com/kern/minitest-reporters/blob/master/lib/minitest/reporters/base_reporter.rb | |
module Minitest | |
module Reporters | |
class NotificationReporter < Minitest::StatisticsReporter | |
attr_accessor :tests | |
def initialize(options={}) | |
super($stdout, options) | |
self.tests = [] | |
end | |
def add_defaults(defaults) | |
self.options = defaults.merge(options) | |
end | |
def record(test) | |
super | |
end | |
def before_test(test) | |
end | |
def after_test(test) | |
tests << test | |
end | |
def report | |
super | |
title_header = "[OK]" | |
face = "^_^" | |
unless tests.map{|t| t.failures.empty?}.all? | |
title_header = "[NG]" | |
face = "orz" | |
end | |
TerminalNotifier.execute(false, :message => "#{face}", :title => "#{title_header} #{tests.first.class.to_s}") rescue nil | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment