travis-cirspec-railsprivate-pub

Travis CI. How to make pass specs which use Faye server?


Private pub gem needs additional Faye server to service message queues. It is started in parallel to rails server with command: rackup private_pub.ru -s thin -E production

This server is also needed in order some specs to pass. So I include its startup command in .travis.yml:

language: ruby
services:
  - postgresql
  - rack

before_script:
  - rackup private_pub.ru -s thin -E production
  - cp config/database.yml.travis config/database.yml
  - psql -c 'create database travis_ci_test;' -U postgres

but during build this command raises error:

0.00s$ rackup private_pub.ru -s thin -E production
/home/travis/build.sh: line 45: rackup: command not found
The command "rackup private_pub.ru -s thin -E production" failed and exited with 127 during .

What am I doing wrong?


Solution

  • The rackup command isn't being found. You'll want to run rackup using bundler exec like this (assuming rack, etc. is in your Gemfile):

    before_script:
      - bundle exec rackup private_pub.ru -s thin -E production &
    

    Using bundle exec uses what is in your gemfile instead of what is on the system (in this case, it's not on the system so you are getting an error). Here's a great link that explains a little bit more about rack and bundle exec: https://robots.thoughtbot.com/but-i-dont-want-to-bundle-exec

    On Travis, you also do not need to add rack to services, just have it in your Gemfile. :)