By now we know that testing is important or more than that, vital!! so our apps will always have tests. If you have your code on Github the there is the possibility of using Travis CI as a Continuous Integration Service that is free for Open Source projects. So every time you do a commit, your tests will be run by Travis and you’ll be notified by mail if they pass or not.
Travis CI documentation is great, everything explained but sometimes when you have a simple project, you just don’t want to go through all the documentation, figure out how it all works, etc you expect to be able to copy&paste a simple configuration file and done.
So, I’ll share the files for a simple case like the webcalendar. Where for testing I’m using rspec, the test DB is sqlite and since the app is deployed in heroku my production DB is postgresql. The configuration files needed are config/database.yml and .travis.yml
The database.yml file looks like
sqlite: &sqlite
adapter: sqlite3
database: db/<%= Rails.env %>.sqlite3
postgresql: &postgresql
adapter: postgresql
username: postgres
password:
database: webcalendar_<%= Rails.env %>
min_messages: ERROR
defaults: &defaults
pool: 16
timeout: 5000
host: localhost
<<: *<%= p ENV[‘DB’] || “sqlite” %>
development:
<<: *defaults
test:
<<: *defaults
production:
<<: *defaults
Don’t worry about seeing here the user and password of the postgreql DB, they work on Travis but are not the ones used in Heroku 😛 …
The .travis.yml file on your root directory that looks like
rvm:
1.9.3
env:
– DB=sqlite
– DB=postgresql
before_script:
– psql -c ‘create database webcalendar_test;’ -U postgres
script:
– RAILS_ENV=test bundle exec rake –trace db:migrate spec
Using this configuration files is working for me, so I help is of some help to some else and does not have to spend a couple of hours trying to figure out how to make travis-ci work on your github account 🙂
RT @carolina: Testing your rails application with Travis and Github #hackership http://t.co/8fXwG8QxmN