Skip to content

Instantly share code, notes, and snippets.

@pacojp
Created December 17, 2014 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pacojp/0ec37d85bc32d6d3eec1 to your computer and use it in GitHub Desktop.
Save pacojp/0ec37d85bc32d6d3eec1 to your computer and use it in GitHub Desktop.
miintest5でterminal-notifierを使うサンプル
# 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