Skip to content

Instantly share code, notes, and snippets.

@johnbintz
Created April 15, 2011 14:05
Show Gist options
  • Save johnbintz/921751 to your computer and use it in GitHub Desktop.
Save johnbintz/921751 to your computer and use it in GitHub Desktop.
Basic Autotest mapping/exception configuration bits
# Actually .autotest and lives at the root of your project, from where you execute autotest
# this is all done in a hook, like this:
Autotest.add_hook :initialize do |at|
# i don't like the default exceptions, get rid of them!
at.clear_exceptions
# exclude stuff that changes between each test, like log
at.add_exception('log/')
# i don't like the default mappings, get rid of them!
at.clear_mappings
# watch some files in addition to what your test framework discovery declares
at.add_mapping(%r{some/testable/code/(.*)\.rb}, true) do |filename, matches|
# the true is to prepend this to the list of matches, leave it blank to append
# this block expects and array of file paths to add to the command line executed
# this will essentially do Dir[whatever] for you, except with a regexp.
# oh yeah, and add that additional file we need to run in the test suite:
at.files_matching(%r{tests/for/my/code/#{matches[1]}_test.rb}) + [ 'some/crazy/test/thing_test.rb' ]
end
end
# discoveries define a set of matchings and exceptions
# you override those with .autotest
Autotest.add_discovery { "rspec2" } # or whatever your testing framework provides
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment