Integration is a Ruby on Rails plugin that provides a set of tasks to automate all steps of a synchronous continuous integration process, that is, continuous integration without a server such as CruiseControl. Why? Because that's the way we like it!


ruby script/plugin install git://

After installing the plugin is ready to be used and you will need to execute only one task in order to integrate your code safely:

rake integrate


Integration Steps

The integration process is composed of several steps that are explained ahead. It's possible to skip one or more steps and add other steps of your own. This will be demonstrated shortly. The complete set of steps are:

  1. task scm:status:check

    Check if all local files are under control of your scm. If your scm is subversion, it also checks if no local files have been removed using only rm (file removal should always use svn remove instead).

  2. task log:clear

    Remove log files.

  3. task tmp:clear

    Remove temporary files.

  4. task backup:local

    Backup files locally. This is done before scm update to create a recovery point if you have problems during scm update. If a file merge creates undesirable effects on the software, you can recover from the backup file. Backup file names have a timestamp. By default, the last 30 backups are kept. You may change this number as you'll see shortly. This task won't work on Windows because it uses tar. So, if you're using Windows you'll have to write your own version of this task or just stop using Windows. We highly recommend the later.

  5. task scm:update

    Update local files from your remote scm repository.

  6. task db:migrate

    Execute any new database migration created by other team members since the last integration.

  7. test:units

    Run all unit tests.

  8. test:functionals

    Run all functional tests.

  9. test:integration

    Run all integration tests.

  10. spec:lib

    Run all lib specs.

  11. spec:models

    Run all model specs.

  12. spec:helpers

    Run all helper specs.

  13. spec:controllers

    Run all controller specs.

  14. spec:views

    Run all view specs.

  15. test:rcov:units

    Run coverage analysis of the unit tests.

  16. test:rcov:units:verify

    Check if unit tests cover 100% of the application code.

  17. test:rcov:functionals

    Run coverage analysis of the functional tests.

  18. test:rcov:functionals:verify

    Check if functional tests cover 100% of the application code.

  19. spec:rcov

    Run coverage analysis of the specs.

  20. spec:rcov:verify

    Check if specs cover 100% of the application code.

  21. test:plugins:selected

    Run tests on selected plugins. You might want to always run the tests of plugins you created, for example, while ignoring the tests of third party plugins. We'll show below how you can specify the plugins you want to test.

  22. spec:plugins:selected

    Same as previous step, but with specs, instead of tests.

  23. test:selenium:server:start

    If you use Selenium to test your application, as you certainly should, you'll need to make sure the webserver is up and running before running Selenium tests. That's what this task does.

  24. test_acceptance

    Run all Selenium tests.

  25. test:selenium:server:stop

    Stop the webserver.

  26. scm:commit

    Commit your changes. If any of the previous tasks break, because one test failed, for instance, the script won't commit. Actually this task runs only if every checking done before work well.

Using this almost paranoid sequence of steps it will be hard to check in bad code in your repository, which is good, very good. The idea is that you should treat your repository as a sacred place, where only good code should ever enter.

Customize the integration process

To customize the integration process you need to create a task file in your project, like:


Changing scm

By default the integration process uses subversion, but you can customize it to use git(your remote repository is git) or git-svn(your remote repository is svn, but you uses git locally):

Skipping tasks

In your custom integration rake file you may define a comma separated list of tasks that you don't want to execute. Let's see some examples:

You can also define SKIP_TASKS when you run the integration process like this:

rake integrate SKIP_TASKS=spec:rcov,spec:rcov:verify

Adding other tasks

Integration plugin also defines callback tasks that you can use to customize it with your own tasks. You can add other tasks before or after any of the plugin tasks. Let's see an example. Say you want to sweep HTML cache pages after running Selenium. To do that, you've just created a task cache:sweep. Let's configure Integration to run it just after Selenium:

    namespace :test_acceptance do
        desc 'Runs cache sweeper'
        task :after do

A callback task is one that has the same name of a plugin task followed by :before or :after. In this case, the plugin defines a task called test_acceptance. So, you may create test_acceptance:before that will be executed before test_acceptance and test_acceptance:after to execute as soon as test_acceptance finishes. To do that, you will need to use namespaces, like we did in the previous example. Now, let's see a real example from one of our projects:

def integration_sweeper
  sh "script/integration_sweeper"

namespace :scm do
  namespace :status do
    namespace :check do
      task :before do

desc 'Generates error 500 page'
task :error500 do
  `curl http://localhost:4000/server_error -o #{RAILS_ROOT}/public/500.html`

namespace :cache do
  namespace :sweeper do
    desc 'Runs cache_sweeper before executing Selenium'
    task :start do

    desc 'Runs cache_sweeper after executing Selenium'
    task :stop do

namespace :test_acceptance do
  desc 'Runs cache sweeper and generate static 500 error page'
  task :before do

  desc 'Runs cache sweeper'
  task :after do

Defining the list of plugins for which you want to run tests or specs

In your integration process, you may want to run tests or specs for certain plugins. All you need to do is name them, like this:

ENV['PLUGINS_TO_TEST'] = "packr, email"
ENV['PLUGINS_TO_SPEC'] = "brazilian_rails"

You can also inform these when you run rake integrate:

rake integrate PLUGINS_TO_TEST=packr,email PLUGINS_TO_SPEC=brazilian_rails

Defining the environment in which to run the integration process

Integration will run against the development environment by default. If you need it to run using another environment, you can do this:

ENV['RAILS_ENV'] = 'development_cache'

Once again, you can also inform this while running rake integrate:

rake integrate RAILS_ENV=test

Selenium port

When running Selenium, you might need to specify another port other them the default port 4000. That's how you do it:


Number of backups to keep

If you want to change the number of backups that will be kept, use this:


Backups are store in a sibling directory with the prefix 'backup-'. For instance, suppose you have a project 'amazing' in the projects directory. After the first backup, you will end up with something like this:


Commit messages

If you don't care to write commit messages, you can skip them:


More examples

You can see more examples in the samples directory.


Discussion about the Integration Plugin are welcome on the forum below:


Integration version 0.2.4

Release Notes


This code is free to be used under the terms of the MIT license.


Comments are welcome. Send your feedback through the forum or to this page


Marcos Tapajós
Vinícius Teles

Shameless advertisement

This plugin is brought to you by Improve It.

Improve It