1

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?

nullnullnull
  • 8,039
  • 12
  • 55
  • 107
  • Why do you want to migrate your test db when you are calling db:test:prepare? – BroiSatse Feb 05 '14 at 00:46
  • It's based on the code I found [here](http://stackoverflow.com/questions/10591599/rake-dbmigration-not-working-on-travis-ci-build). Honestly, I have no idea why this is failing, so I've tried just mimicking what worked for others. – nullnullnull Feb 05 '14 at 00:50

1 Answers1

6

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
Community
  • 1
  • 1
nullnullnull
  • 8,039
  • 12
  • 55
  • 107