-
-
Save nathanclark/293012 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# autotest your engine plugins | |
# at this point, requires my autotest fork, http://github.com/whatcould/zentest/tree/master | |
Autotest.add_hook :initialize do |at| | |
# all your plugins with an app directory | |
engine_plugins = [] | |
Dir.glob('vendor/plugins/*').each do |dir| | |
engine_plugins << dir if File.directory?("#{dir}/app") | |
end | |
# this big requires my autotest fork | |
at.extra_test_paths = engine_plugins.map{|p| p + '/test'} | |
# autotest comes with an exception for your vendor; have to get rid of that | |
at.remove_exception(%r%^\./(?:db|doc|log|public|script|tmp|vendor)%) | |
at.add_exception %r%^\./(?:db|doc|log|public|script|tmp)% | |
at.add_exception(/^\.\/vendor\/rails/) | |
at.add_exception(/^\.\/vendor\/gems/) | |
# exceptions for all your non-engine plugins | |
plugin_names = engine_plugins.map{|p| p.sub('vendor/plugins/','')} | |
at.add_exception(%r%vendor/plugins/(?!#{plugin_names.join('|')})%) | |
engine_plugins.each do |plugin_path| | |
at.add_exception("#{plugin_path}/db") | |
# these mirror the mappings in the autotest rails profile | |
# | |
# TODO: these don't account for overriding methods, views, etc in your app | |
# eg, a change in your main app/ doesn't run the corresponding test in the plugin/app | |
at.add_mapping %r%^#{plugin_path}/app/models/(.*)\.rb$% do |_, m| | |
"#{plugin_path}/test/unit/#{m[1]}_test.rb" | |
end | |
at.add_mapping %r%^#{plugin_path}/app/controllers/(.*)\.rb$% do |_, m| | |
["#{plugin_path}/test/controllers/#{m[1]}_test.rb", | |
"#{plugin_path}/test/functional/#{m[1]}_test.rb"] | |
end | |
at.add_mapping %r%^#{plugin_path}/app/helpers/(.*)_helper.rb% do |_, m| | |
["#{plugin_path}/test/views/#{m[1]}_view_test.rb", | |
"#{plugin_path}/test/functional/#{m[1]}_controller_test.rb"] | |
end | |
at.add_mapping %r%^#{plugin_path}/app/views/(.*)/% do |_, m| | |
["#{plugin_path}/test/views/#{m[1]}_view_test.rb", | |
"#{plugin_path}/test/functional/#{m[1]}_controller_test.rb"] | |
end | |
# changes in routes test your app functional tests as well | |
at.add_mapping %r%^#{plugin_path}/config/routes.rb$% do | |
at.files_matching %r%^(#{plugin_path}/)?test/(controllers|views|functional)/.*_test\.rb$% | |
end | |
at.add_mapping %r%^#{plugin_path}/test/(unit|integration|controllers|views|functional)/.*rb$% do |filename, _| | |
filename | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment