Ubuntu上使用autotest做Rails项目的自动测试 - autotest安装和测试
Automate Everything: Ruby, Linux and other hints, tips and tricks.Gnome and Autospec Notifications注:不需要安装autotest (参考Ruby on Rails 3 Tutorial:3.2.1 Testing tools),好像是ZenTest里面有autotest了。安
·
Automate Everything: Ruby, Linux and other hints, tips and tricks.
Gnome and Autospec Notifications
注:不需要安装autotest (参考Ruby on Rails 3 Tutorial: 3.2.1 Testing tools),好像是ZenTest里面有autotest了。
$ sudo gem install ZenTest $ sudo gem install redgreen
然后安装libnotify-bin package
$ sudo apt-get install libnotify-bin
在Home目录创建文件 ~/.autotest 内容如下
和原文Automate Everything 唯一不同的地方是要掉redgreen那一行。
#!/bin/ruby
# remove this line on Unbuntu 11 : require 'redgreen'
require 'autotest/timestamp'
module Autotest::GnomeNotify
def self.notify title, msg, img
system "notify-send '#{title}' '#{msg}' -i #{img} -t 3000"
end
Autotest.add_hook :ran_command do |at|
image_root = "~/.autotest_images"
results = [at.results].flatten.join("\n")
results.gsub!(/\\e\[\d+m/,'')
output = results.slice(/(\d+)\sexamples?,\s(\d+)\sfailures?(,\s(\d+)\spending?|)/)
full_sentence, green, failures, garbage, pending = $~.to_a.map(&:to_i)
if output
if failures > 0
notify "FAIL", "#{output}", "#{image_root}/fail.png"
elsif pending > 0
notify "Pending", "#{output}", "#{image_root}/pending.png"
else
notify "Pass", "#{output}", "#{image_root}/pass.png"
end
end
end
end
下载红绿图片到目录~/.autotest_images/.
参考:
Rails项目配置rspec: Ruby on Rails 3 Tutorial: 3.2.1 Testing tools
安装配置:Automate Everything
安装配置:http://jetpackweb.com/blog/2009/09/01/autotest-notifications-on-ubuntu-using-lib-notify/
更多推荐
已为社区贡献3条内容
所有评论(0)