autowatchr

Provides some autotest-like behavior for watchr (github.com/mynyml/watchr).

Installation

gem install autowatchr --source http://gemcutter.org

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

Todo

  • Cucumber support

  • Expose algorithm to map test classes to test files

  • Add INT signal trapping

Example use

test.watchr

require 'autowatchr'

Autowatchr.new(self) do |config|
  config.ruby = 'jruby'
  config.lib_dir = 'leet_lib'
  config.test_dir = 'leet_test'
end

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 library files

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

  • 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.

Copyright © 2009 Jeremy Stephens. See LICENSE for details.

Many snippets were taken from ZenTest.