Skip to content

Instantly share code, notes, and snippets.

@seandenigris
Created March 1, 2010 03:17
Show Gist options
  • Save seandenigris/318054 to your computer and use it in GitHub Desktop.
Save seandenigris/318054 to your computer and use it in GitHub Desktop.
use non-standard naming convention with Rspec and autotest
# .autotest file to use non-standard names with autotest and Rspec (e.g. "example" instead of "spec")
class Autotest::Rspec < Autotest
remove_method :consolidate_failures
def consolidate_failures(failed)
filters = new_hash_of_arrays
failed.each do |spec, trace|
if trace =~ /\n(\.\/)?(.*example\.rb):[\d]+:/
filters[$2] << spec
end
end
return filters
end
remove_method :add_options_if_present
def add_options_if_present # :nodoc:
File.exist?("examples/spec.opts") ? "-O examples/spec.opts " : ""
end
end
Autotest.add_hook(:initialize) {|at|
%w{.git .svn .hg .swp .DS_Store ._* tmp}.each do |exception|
at.add_exception(exception)
end
at.clear_mappings # take out the default (test/test*rb)
at.add_mapping(%r%^(examples|third_party)/.*_example.rb$%) { |filename, _|
filename
}
at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
["examples/#{m[1]}_example.rb"]
}
at.add_mapping(%r%^examples/(example_helper|shared/.*)\.rb$%) {
at.files_matching %r%^(examples|third_party)/.*_example\.rb$%
}
nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment