Run Tests on Deploy plugin

Plugin details

This plug-in is a Capistrano extension. It requires Capistrano 2.0.0 or greater.

Websitehttp://spattendesign.com/2007/10/19/running-tests-on-deploy Repositorysvn://svn.spattendesign.com/svn/plugins/run_tests_on_deploy Tags Capistrano LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install svn://svn.spattendesign.com/svn/plugins/run_tests_on_deploy

The plugin adds the following tasks:

deploy:run_tests
  deploy:without_tests



Once installed, running

  cap deploy



will run all of your tests before doing the final symlink. If the tests fail, the symlink will not be created and your deployment will roll back.

The deploy:run_tests task is executed before the symlink task. The run_tests task does the following:

* prepares your test db with rake db:test:prepare
* runs all of your tests with "rake test" at a nice level of -10

The deploy:run_tests tasks won’t work if you call it by itself, as it runs from the release_path directory, which won’t exist unless called after deploy:update_code.

to deploy without tests:

  cap deploy:without_tests



you can also set the run_tests option to 0 from the command line like this:

  cap -S run_tests=0 deploy



this allows you to do things like deploying with migrations but without tests:

  cap -S run_tests=0 deploy:migrations



The original idea for the :run_tests task is from blog.testingrails.com/2006/9/4/running-tests-on-deploy-with-capistrano, which, sadly, seems to be defunct.
Installation

  script/plugin install run_tests_on_deploy



Capistrano configuration

This plugin requires Capistrano 2.0.0 or greater. To upgrade to the latest version (currently 2.1.0)

  gem install capistrano



Once the plug-in is installed, make sure that the recipes are seen by Capistrano

cap -T | grep deploy:without_tests



should return

  cap deploy:without_tests          # deploy without running tests



If capistrano is not seeing the deploy:without_tests task, then you need to update your Capfile.

(The following is from Jamis Buck, in groups.google.com/group/capistrano/browse_thread/thread/531ad32aff5fe5a8)

In Capistrano 2.1.0 or above: you can delete your Capify file in rails root, and then, from rails root, run

  capify .



If you do not want to delete your Capify file, or if you are using Capistrano 2.0.0, add the following line to your Capify file:

  Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }


Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | Back in time (2 older versions) | Last edited by: scott, about 1 year ago