Ubuntu + Rails + RSpec + ZenTest + Notify Ubuntu + Rails + RSpec + ZenTest + Notify

| コメント(0) | トラックバック(0)
Railsのテスト環境を改めて- MacOSX / RSpec / ZenTest / Growl:TKMR.blog.show

こちらの記事にあることと同じことをUbuntuでもやりたいと思った。できたので備忘録。

Ubuntu +Rails + Rspec + ZenTest + Notify

必要な手順は参照先とほとんど同じである。変更点は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パッケージにサンプルモジュールがあるが、なぜかそれは動いてくれない。なのでこれで代用。すばらしいです。

トラックバック(0)

トラックバックURL: http://colspan.net/mt/mt-tb.cgi/216

コメントする

月別 アーカイブ

about Colspan


1983年生。技術系会社員。
趣味はJavascript。
韓国語を少し話す。
Twitter
Hatena
Zooomr
Flickr

このブログ記事について

このページは、Colspanが2007年12月 8日 18:40に書いたブログ記事です。

ひとつ前のブログ記事は「サンワサプライのモニター当選」です。

次のブログ記事は「Zooomr Uploader」です。

最近のコンテンツはインデックスページで見られます。過去に書かれたものはアーカイブのページで見られます。