Skip to content

harmon/autowatchr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

autowatchr

Fork of viking’s autowatchr library (github.com/viking/autowatchr) to fix issues and add features. Provides some autotest-like behavior for watchr (github.com/mynyml/watchr).

Installation

gem install harmon-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.

Todo

  • Cucumber support

  • Expose algorithm to map test classes to test files

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"

  • run_method

    • The way the ruby files are “require”-ed.

    • Two options:

      • :require => ruby -e "%w[test/first_test.rb test/second_test.rb].each { |file| require file }"

      • :load => ruby -e "%w[test/first_test.rb test/second_test.rb].each { |file| load file }"

    • Default: :require

    • It is advised to use :load when running tests in Rails since that is what “rake test” uses.

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

Contributors

  • Adam Grant (harmon)

About

Provides some autotest-like behavior for watchr

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%