notapatch
notapatch

Reputation: 7173

Testing Capistrano deployments and Gems

Ruby has a testing culture. So I was surprised to find that there were no testing details about Capistrano.

What are the options for testing Capistrano deploys and Gems?

Upvotes: 1

Views: 986

Answers (2)

Matt Brictson
Matt Brictson

Reputation: 11092

The Capistrano project itself does have a testing culture and includes integration tests (Cucumber "features") that use a Vagrant VM to take the place of a remote server. These tests are somewhat slow to run, require special tools (e.g. Virtual Box), and do not work in Travis CI. Hence this style of integration testing has never caught on with the wider Capistrano community of third-party gems.

However, Capistrano has recently made improvements to formalize its plugin system and to make these plugins easier to unit test. For example, the SCM implementations built into Capistrano now all use this new plugin system, and have corresponding tests.

My hope is that new Capistrano gems will take advantage of the plugin architecture and provide better tests. If you are planning on writing your own Capistrano task libraries, refer to the SCM tests for testing strategies, and feel free to suggest improvements.

If you are not developing a gem, but simply using Capistrano to deploy an application: Your deployment will be unique to your particular project, based on a combination of various Capistrano gems, configuration, server environment, etc. The only real way to test your deployment is by using a staging environment.

Upvotes: 2

notapatch
notapatch

Reputation: 7173

Summary

Most recipes are not tested. Test deployments on a staging server.

Detail

Most recipes are not tested.

The reason according to Lee Hambley (a Capistrano maintainer) is that:

  1. Capistrano was architectured before the testing culture developed
  2. Test cases in a spec do not resemble the server environment that will be executed against.

In addition:

The advice is to have a staging environment to 'test' against before using production.

Upvotes: 0

Related Questions