不知道如何在Travis CI中构建任务'db:migrate'

时间:2014-02-05 00:43:17

标签: ruby-on-rails ruby travis-ci

我有以下.travis.yml文件:

language: ruby
rvm:
  - "2.0.0"
# uncomment this line if your project needs to run something other than `rake`:
before_script:
  - psql -c "create database dummy_test;" -U postgres
  - psql -c "CREATE USER dummy WITH PASSWORD 'dummy';" -U postgres
script:
  - RAILS_ENV=test bundle exec rake db:migrate --trace
  - bundle exec rake db:test:prepare
  - bundle exec rspec spec

当我尝试在Travis CI中运行它时,我收到以下错误消息:

$ RAILS_ENV=test bundle exec rake db:migrate --trace
rake aborted!
Don't know how to build task 'db:migrate'

我几个小时都在尝试不同的方法。我做错了什么?

1 个答案:

答案 0 :(得分:5)

终于搞定了。

问题是该应用程序是隐藏在spec/dummy内的虚拟应用程序,因此运行rake db:migrate将无法从根目录运行。为了解决这个问题,我遵循了here给出的建议。编辑Rakefile以指向spec/dummy,然后运行rspec测试:

APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
require "rspec/core/rake_task"

task :default => :spec

RSpec::Core::RakeTask.new(:spec) do |spec|
  spec.pattern = 'spec/**/*_spec.rb'
  # spec.rspec_opts = ['-cfs --backtrace']
end