public
Description: Behaviour Driven Development framework for Ruby
Home | Edit | New

Autotest Integration

See http://zentest.rubyforge.org/ZenTest/Autotest.html first.

RSpec wraps the autotest command with an autospec command

rspec overrides the existing mappings in autotest/rspec.rb

rspec-rails overrides them further in autotest/rails_rspec.rb

Autotest will load ~/.autotest and ./.autotest (in that order) after it loads up RSpec’s autotest subclasses, so you can further modify things in those files. For example, if you want to clear existing mappings, and add new mappings of your own, while also ignoring any temp file created by cucumber, you get something like this:

Autotest.add_hook(:initialize) {|at|
  at.add_exception %r{^\.git}  # ignore Version Control System
  at.add_exception %r{^./tmp}  # ignore temp files, lest autotest will run again, and again...
  #  at.clear_mappings         # take out the default (test/test*rb)
  at.add_mapping(%r{^lib/.*\.rb$}) {|f, _|
    Dir['spec/**/*.rb']
  }
  nil
}

The nil makes sure that other :initialize hooks get executed (in the case of add_mapping or add_exception, nil is already returned)
Very relevant if you have both ~/.autotest and .autotest

I run autotest/spec like this


$ RUBYLIB=./lib RUBYOPT=-rubygems AUTOFEATURE=true autospec

but you may find this to be good enough:

$ RUBYLIB=./lib RUBYOPT=-rubygems autotest

Though autotest/spec will rerun when you modify .autotest, it will not execute the :initialize hook, you have to press ^C twice and restart autotest/spec.

Also see Cucumber’s Autotest Integration

Enable growl notifications (optional, for Mac OSX)

Install the autotest-growl gem:

$ sudo gem install autotest-growl

In your ~/.autotest or ./.autotest file, add:

require 'autotest/growl'
Last edited by moklett, Thu Sep 24 06:41:05 -0700 2009
Home | Edit | New
Versions: