// Richard Hart / Hates_

Autotest would constantly run my tests even though I hadn’t modified anything. Which made it impossible to actually use. Creating the following in a file called .autotest in my application’s root solved the problem for me. This is on Rails 3 RC, RSpec 2 beta 19 and Cucumber 0.8.5.

  Autotest.add_hook :initialize do |at|
    at.add_exception(%r{^\./\.git})
    at.add_exception(%r{^\./db})
    at.add_exception(%r{^\./log})
    at.add_exception(%r{^\./tmp})
    at.add_exception(%r{^\./rerun\.txt})
    at.add_exception(%r{^\./Gemfile\.lock})
  end
UPDATE: Updated with Wes' suggestion in the comments.
3 comments
  1. Gregório Melo says: September 24, 201011:39 am

    Great tip! Exactly what I had and the solution I needed.

    Thanks!

  2. Wes Morgan says: January 20, 20115:49 pm

    Not that it makes a huge difference, but shouldn’t those last two be:

    at.add_exception(%r{^\./rerun\.txt})
    at.add_exception(%r{^\./Gemfile\.lock})

    (Added a backslash before the dot at the beginning of the file extension.)

    • Richard says: January 21, 20112:01 pm

      Yup, totally right. Both will work but yours is the proper way.

Submit comment