论坛首页 编程语言技术论坛

配置CruiseControl.rb支持RSpec

浏览 1858 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2009-03-29   最后修改:2009-03-29
   CruiseControl对于Rails程序有很大的帮助,但是一直是在传统的test cases测试下使用.现在想使用基于RSpec的项目中,使用CruiseControl.那么,可以按照如下的步骤安装:
    rake db:test:purge
    rake db:migrate
    rake test

但是,默认情况下CruiseControl在执行build的时候仍然执行Rails自带的test cases所以我们可以做如下的改变,使得CruiseControl能够调用RSpec的测试.
那么,创建如下的rake任务:

RAILS_ROOT/lib/tasks/custom_cc.rake


   desc 'Custom curise task for RSpec'  
   task :cruise do  
         ENV['RAILS_ENV'] = 'test'  
     
         if File.exists?(Dir.pwd + "/config/database.yml")  
           if Dir[Dir.pwd + "/db/migrate/*.rb"].empty?  
             raise "No migration scripts found in db/migrate/ but database.yml exists, " +  
                   "CruiseControl won't be able to build the latest test database. Build aborted."  
           end  
     
              #perform standard Rails database cleanup/preparation tasks if they are defined in project  
              #this is necessary because there is no up-to-date development database on a continuous integration box  
           if Rake.application.lookup('db:test:purge') 
             CruiseControl::invoke_rake_task 'db:test:purge' 
           end 
    
           if Rake.application.lookup('db:migrate') 
             CruiseControl::reconnect 
             CruiseControl::invoke_rake_task 'db:migrate' 
           end 
         end 
    
         CruiseControl::invoke_rake_task 'spec:all'  
   end 


这样,CruiseControl.rb就可以在build的时候调用RSpec了.
论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics