Automated Testing: Autotest and Autospec

Installation (Base)

Remember to include gemcutter as gem repository if you haven't done it already:

gem sources --add

The basic installation is done through the following commands:
sudo gem install ZenTest
sudo gem install autotest-rails

Integrating with Rspec

You need to install Rspec:

sudo gem install rspec rspec-rails

Then you can run the following command to run your tests:


Integrating with Cucumber

You need to install Cucumber:

sudo gem install cucumber

Then you can run the following command to run your features and tests:

AUTOFEATURE=true autotest


AUTOFEATURE=true autospec

Integration with Growl (Mac OS X Only)

You need to install autotest-growl gem:

sudo gem install autotest-growl

And require it in your .autospec file (see below for more info):

require 'autotest/growl'

Customizing with .autotest

Sometimes you want to exclude certain directories from being watched for changes. This may prevent autotest to keep running tests indefinetly:

Create a .autospec file in the root of your project:

cd my_project
touch .autospec

Write the following snippet, customizing to your needs:

Autotest.add_hook :initialize do |autotest|
  %w{.git .svn .hg .DS_Store db log tmp vendor ._* .sqlite3 rerun.txt}.each do |exception|

External Links

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License