【问题标题】:Don't know how to build task 'db:migrate' in Travis CI不知道如何在 Travis CI 中构建任务 'db:migrate'
【发布时间】:2014-02-05 09:24:48
【问题描述】:

我有以下.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'

几个小时以来,我一直在尝试不同的方法。我做错了什么?

【问题讨论】:

  • 为什么在调用 db:test:prepare 时要迁移测试数据库?
  • 它基于我找到的代码here。老实说,我不知道为什么会失败,所以我试着模仿对别人有用的方法。

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


【解决方案1】:

终于搞定了。

问题在于该应用程序是隐藏在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

【讨论】:

    猜你喜欢
    • 2018-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-23
    • 2013-02-01
    • 2016-01-20
    • 2014-04-15
    • 1970-01-01
    相关资源
    最近更新 更多