gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 17:34:26 25 4
gpt4 key购买 nike

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

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

最佳答案

终于成功了。

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

关于ruby-on-rails - 不知道如何在 Travis CI 中构建任务 'db:migrate',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21566530/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com