Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Provides some autotest-like behavior for watchr
branch: master
Failed to load latest commit information.
lib Change path separator (via luislavena)
test Made rubygems optional for testing autowatchr
.document Initial commit to autowatch.
.gitignore Initial commit to autowatch.
LICENSE Initial commit to autowatch.
Rakefile require 'stringio'
VERSION Version bump to 0.1.5
autowatchr.gemspec Regenerated gemspec
test.watchr Made rubygems optional for testing autowatchr



Provides some autotest-like behavior for watchr (


gem install autowatchr

Current features

  • Auto-watches test and lib files using the autotest layout

  • Optionally run only failing-tests

  • Optionally run entire suite after all tests pass

  • Traps INT signal (Control-C) and re-runs all tests.


  • Cucumber support

  • Expose algorithm to map test classes to test files

Example use

Create a .watchr file for your project and simply declare an Autowatchr block within it:

# test/test.watchr
require 'autowatchr' do |config|
  config.ruby = 'jruby'
  config.lib_dir = 'leet_lib'
  config.test_dir = 'leet_test'

Your tests can then be run with:

$ watchr test/test.watchr

Configuration options

  • command

    • An ERB template for the command

    • Default: "<%= ruby %> -I<%= include %> <% list_of_requires.each { |lib| %>-r<%= lib %> <% } %><%= predicate %>"

  • ruby

    • The ruby executable to use

    • Default: "ruby"

  • include

    • Paths to include (with -I)

    • Default: ".:#{self.lib_dir}:#{self.test_dir}"

  • require

    • Libraries to include (with -r)

    • Can either be a string or an array (Ex: config.require = %w{rubygems active_support})

    • Default: nil

  • lib_dir

    • The lib path, where your library lives

    • Default: "lib"

  • test_dir

    • The test path, where your tests live

    • Default: "test"

  • lib_re

    • The regexp to use for discovering library files

    • Default: '^%s./.\.rb$' % self.lib_dir

  • test_re

    • The regexp to use for discovering test files

    • Default: '^%s./test_.\.rb$' % self.test_dir

  • test_file

    • The filename pattern for correlating test files with lib files. The %s will be substituted for the basename of the lib file.

    • Default: 'test_%s.rb'

  • failing_only

    • Run only failing tests the next time a test file is run

    • Default: true

  • run_suite

    • Run entire test suite after failing tests pass

    • Default: true

All of the config options are optional. You can also pass in a hash instead of a block. Also see: test.watchr.

Using with RSpec

Autowatchr can easily be configured to work with the standard RSpec file hierarchy:

# spec/spec.watchr
require 'autowatchr' do |config|
  config.test_dir = 'spec'
  config.test_re = "^#{config.test_dir}/(.*)_spec\.rb$"
  config.test_file = '%s_spec.rb'

Be sure you have spec_helper.rb required in every spec file, or else put it in your .watchr file.

Prettier Results

Autowatchr is compatible with the Watchr redgreen gem. Install 'mynyml-redgreen' and simply require it in your .watchr file.


Copyright © 2011 Jeremy Stephens. See LICENSE for details.

Many snippets were taken from ZenTest.


  • Stephen Eley (SFEley)

  • Adam Grant (harmon)

Something went wrong with that request. Please try again.