I was shocked to discover that Capistrano doesn’t run the tests by default on deploy. The coolest part of capistrano isn’t even turned on. Beyond that, it’s not even documented in the capistrano manual. So, i’m here to fill the gap.

The first thing to do is a task for running the tests.

desc "Run the full tests on the deployed app." 
task :run_tests do
 run "cd #{release_path} && rake db:test:prepare" 
 run "cd #{release_path} && rake" 
end

desc "Run pre-symlink tasks" 
task :before_symlnk do
  run_tests
end