سؤال

I have the following .travis.yml file:

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

When I try running it in Travis CI, I get this error message:

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

I've been trying different approaches for hours. What am I doing wrong?

هل كانت مفيدة؟

المحلول

Finally got it working.

The issue was that the application was a dummy application buried within spec/dummy, so running rake db:migrate wouldn't work from the root directory. In order to fix this, I followed the advice given here. Edit the Rakefile to point to spec/dummy and then run rspec tests:

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
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top