My Travis CI builds are failing when it tries to run RSpec. Here is my .travis.yml
:
language: ruby
script:
- export RAILS_ENV=test
- bundle exec rake db:create db:schema:load db:test:prepare
- bundle exec rake cucumber
- bundle exec rspec
The first three script steps complete successfully and I get Done. Your build exited with 0.
(here)
But when I add the fourth step (bundle exec rspec
) I get Done. Your build exited with 1.
(here)
The error in the build (uninitialized constant CommentsController (NameError)
) comes from the first line in th first file in the "spec/" folder (comments_controller_spec.rb
). Here are the error details from Travis:
$ bundle exec rspec
/home/travis/build/deeprog/goalify/spec/controllers/comments_controller_spec.rb:1:in `<top (required)>': uninitialized constant CommentsController (NameError)
from /home/travis/build/deeprog/goalify/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `load'
from /home/travis/build/deeprog/goalify/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `block in load_spec_files'
from /home/travis/build/deeprog/goalify/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `each'
from /home/travis/build/deeprog/goalify/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `load_spec_files'
from /home/travis/build/deeprog/goalify/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:102:in `setup'
from /home/travis/build/deeprog/goalify/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:88:in `run'
from /home/travis/build/deeprog/goalify/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:73:in `run'
from /home/travis/build/deeprog/goalify/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:41:in `invoke'
from /home/travis/build/deeprog/goalify/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.3.2/exe/rspec:4:in `<top (required)>'
from /home/travis/build/deeprog/goalify/vendor/bundle/ruby/2.2.0/bin/rspec:23:in `load'
from /home/travis/build/deeprog/goalify/vendor/bundle/ruby/2.2.0/bin/rspec:23:in `<main>'
The command "bundle exec rspec" exited with 1.
I am stumped about this error. I have tried adding require 'rails-helper'
/require 'spec_helper'
to the top of the spec, but that didn't help. I've also tried running rake
instead of bundle exec rspec
, but that gives the same error.
The app currently lives at a relative root ('/goalify'
), so to get the tests to run locally I had to set config.relative_url_root = nil
in test.rb
. But removing that line doesn't fix it on Travis, either. I've also added any required environment variables to Travis.
Here is some more info:
Gemfile:
group :development, :test do
gem 'byebug'
gem 'cucumber-rails', require: false
gem 'database_cleaner'
gem 'factory_girl_rails'
gem 'rspec-rails'
gem 'simplecov', require: false
gem 'spring'
gem 'spring-commands-rspec'
gem 'travis'
end
.rspec
--color
--format documentation
--require spec_helper
--require rails_helper
And here is the source on GitHub.