Rails Deployment on the Cheap

Recently I have been working on increasingly complex Rails apps and have been looking for a way to better handle deploying them. That being said, these are apps that only a handful of people are using and are all hosted on Heroku.

The following is the recipe I have pulled together to take the deployment of these apps a bit more seriously while not making it too complilcated. Think $ git push heroku meets $ cap deploy.

NOTE: This post is a work in progress and currently just acting as a placeholder. Check back soon for more.

The following are the slides I used to present this talk at the September 2012 BostonRB lightning talks meeup. After the slides is a bit more detail.

The main focus I had was on increased testing and more so actually ensuring that my test suite ran before I deployed. With the ruby end of my apps, this was easy. Unfortunately (fortunately?) I find myself writing more and more javascript of late and I wanted to get this included.



Jasminerice integrates the asset pipeline into the jasmine testing flow.

Jasmine engine


Guard jasmine

Important Fix

By default, the test environment is set to swallow up parsing errors encountered while working through an asset file. This can cause the guard-jasmine task to incorrectly report a pass with 0 test, 0 failures. In order to avoid this, set config.assets.debug = true in test.rb environment file. The details of this issue can be found here.

Full Stacking It

  1. Heroku use this rake task

  2. Travis drop the following in as your travis test task

# .travis.yml file in project root
language: ruby
  - 1.9.3
script: bundle exec rake travis
# Project Rakefile, or "travis" file in lib/tasks
task :travis do
  ["rspec spec", "guard-jasmine"].each do |cmd|
    puts "Running #{cmd}..."
    system("export DISPLAY=:99.0 && bundle exec #{cmd}")
    raise "#{cmd} failed!" unless $?.exitstatus == 0