Ubuntu11.10+ruby on rails 3+rspec+autotest 配备
Ubuntu11.10+ruby on rails 3+rspec+autotest 配置
step1: 创建新的项目,不包含默认测试文件(-T)
$ rails new sampleapp -T
step2:
$ cd sampleapp
step3:
修改Gemfile
添加
step4:
$ bundle install
step5: 安装rspec
$ rails generate rspec:install
step6: 新建几个页面,【并删掉部分测试(可略过)】
$ rails generate controller Pages home contact
$ rm -rf spec/views
$ rm -rf spec/helpers
step7: 安装autotest(http://automate-everything.com/2009/08/gnome-and-autospec-notifications/#comments)
$sudo gem install ZenTest
【#可能在安装的时候提示gem版本太低,需要~>1.8,需要升级,以下给出升级方法(直接gem update --system是不行的):
#$sudo gem install rubygems-update -v 1.8.24(我安装时的最新版本)
#$sudo update_rubygems
#$sudo gem update --system
#】
$sudo gem install redgreen
$sudo apt-get install libnotify-bin
step8:
新建文件~/.autotest,内容如下
step9:
下载autotest_images.zip,将.autotest_images放到放到~/下,即~/.autotest_images/
下载链接:http://automate-everything.com/wp-content/uploads/2009/08/autotest_images.zip
step10:享受成果。
$cd sampleapp #若已在此目录,略过
$autotest

step1: 创建新的项目,不包含默认测试文件(-T)
$ rails new sampleapp -T
step2:
$ cd sampleapp
step3:
修改Gemfile
添加
gem 'therubyracer' group :development do gem 'rspec-rails' end group :test do gem 'rspec' gem 'webrat' end
step4:
$ bundle install
step5: 安装rspec
$ rails generate rspec:install
step6: 新建几个页面,【并删掉部分测试(可略过)】
$ rails generate controller Pages home contact
$ rm -rf spec/views
$ rm -rf spec/helpers
step7: 安装autotest(http://automate-everything.com/2009/08/gnome-and-autospec-notifications/#comments)
$sudo gem install ZenTest
【#可能在安装的时候提示gem版本太低,需要~>1.8,需要升级,以下给出升级方法(直接gem update --system是不行的):
#$sudo gem install rubygems-update -v 1.8.24(我安装时的最新版本)
#$sudo update_rubygems
#$sudo gem update --system
#】
$sudo gem install redgreen
$sudo apt-get install libnotify-bin
step8:
新建文件~/.autotest,内容如下
#!/bin/ruby require 'redgreen' #若为ubuntu11.*需要去掉此行 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
step9:
下载autotest_images.zip,将.autotest_images放到放到~/下,即~/.autotest_images/
下载链接:http://automate-everything.com/wp-content/uploads/2009/08/autotest_images.zip
step10:享受成果。
$cd sampleapp #若已在此目录,略过
$autotest