Railsのテスト環境を改めて- MacOSX / RSpec / ZenTest / Growl:TKMR.blog.show
こちらの記事にあることと同じことをUbuntuでもやりたいと思った。できたので備忘録。
必要な手順は参照先とほとんど同じである。変更点は11番から。
MacのGrowlに相当するものは、UbuntuではNotifyがある。こちらを利用。
sudo apt-get install libnotify-bin
~/.autotestファイルを以下のような内容にする。
module Autotest::Notify
def self.notify(title, message, priority='critical')
icon = if priority == 'critical'
'dialog-error'
else
'dialog-information'
end
system "notify-send -u #{priority} -t 10000 -i #{icon} '#{title}' '#{message.inspect}'"
end
Autotest.add_hook :ran_command do |at|
results = [at.results].flatten.join("\\n")
output = results.slice(/(\\d+)\\s+examples?,\\s*(\\d+)\\s+failures?(,\\s*(\\d+)\\s+pending)?/)
if output
if $~[2].to_i > 0
notify "Test Results", "#{output}"
else
notify "Test Results", "#{output}", "low"
end
end
end
end
gemパッケージにサンプルモジュールがあるが、なぜかそれは動いてくれない。なのでこれで代用。すばらしいです。











コメントする