Ubuntu11.10+ruby on rails 3+rspec+autotest+spork配置

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

step11:有关spork配置察看链接http://blog.csdn.net/emerald0106/article/details/7251332

注意启动spork时,spork为小写,即

$spork

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值