使用RSpec的CruiseControl.rb:未找到Rake任务'spec'

时间:2012-02-24 12:49:31

标签: ruby ruby-on-rails-3 cruisecontrol cruisecontrol.rb

我正在尝试将CruiseControl.rb(版本2.0.0pre1)与RSpec一起用于我的Ruby on Rails 3应用程序。我项目的cruise_config.rb如下所示:

Project.configure do |project|
  project.rake_task = 'db:migrate db:test:prepare spec'
  project.scheduler.polling_interval = 1.hour
  project.scheduler.always_build = false
end

但是当我尝试使用CruiseControl运行构建时,它说:

rake aborted!
Custom rake task(s) 'spec' not defined

Tasks: TOP => cc:build
(See full trace by running task with --trace)

无法找到运行RSpec测试的spec rake任务。我还尝试在Rakefile内定义自定义rake任务,并删除了project.rake_task = 'db:migrate db:test:prepare spec'中的cruise_config.rb行:

desc "Custom Task for CruiseControl.rb"
task :cruise do
  puts "Custom Rake task"
  Rake::Task['db:migrate'].execute
  Rake::Task['db:test:prepare'].execute
  Rake::Task['spec'].execute
end

如果我这样做,CruiseControl说

rake aborted!
ActiveRecord::ConnectionNotEstablished

Tasks: TOP => cruise
(See full trace by running task with --trace)
[CruiseControl] Invoking Rake task "cruise"
Custom Rake task

是否有人使用CruiseControl.rb与RSpec合作?

1 个答案:

答案 0 :(得分:4)

确保您在:spec中定义了Rakefile任务,对于RSpec 2,它看起来像这样:

require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)