Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PLUGIN_PATH = "vendor/plugins/community_engine/"
- Autotest.add_hook :initialize do |at|
- at.clear_exceptions
- at.clear_mappings
- %w{.git .svn stories tmtags Rakefile Capfile README spec/spec.opts spec/rcov.opts vendor/gems autotest svn-commit .DS_Store }.each do |exception|
- at.add_exception(exception)
- end
- at.add_exception %r%^\./(?:db|doc|log|public|script|tmp)%
- at.add_exception %r%^#{PLUGIN_PATH}(?:app|config|db|generators|lang|lib|plugins|public|sample_files|tasks)%
- at.add_mapping %r%^test/(unit|integration|controllers|views|functional)/.*rb$% do |filename, _|
- [filename, File.join(PLUGIN_PATH, filename)]
- end
- at.add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
- ["test/unit/#{m[1]}_test.rb", "#{PLUGIN_PATH}test/unit/#{m[1]}_test.rb"]
- end
- at.add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
- if m[1] == "application" then
- combine_paths(at, %r%^test/(controllers|views|functional)/.*_test\.rb$%)
- else
- ["test/functional/#{m[1]}_test.rb",
- "#{PLUGIN_PATH}test/functional/#{m[1]}_test.rb"]
- end
- end
- at.add_mapping %r%^app/helpers/application_helper.rb% do
- combine_paths(at, %r%^test/(views|functional)/.*_test\.rb$%)
- end
- at.add_mapping %r%^app/helpers/(.*)_helper.rb% do |_, m|
- if m[1] == "application" then
- combine_paths at, %r%^test/(views|functional)/.*_test\.rb$%
- else
- ["test/views/#{m[1]}_view_test.rb",
- "test/functional/#{m[1]}_controller_test.rb",
- "#{PLUGIN_PATH}test/views/#{m[1]}_view_test.rb",
- "#{PLUGIN_PATH}test/functional/#{m[1]}_controller_test.rb"]
- end
- end
- at.add_mapping %r%^app/views/(.*)/% do |_, m|
- ["test/views/#{m[1]}_view_test.rb",
- "test/functional/#{m[1]}_controller_test.rb",
- "#{PLUGIN_PATH}test/views/#{m[1]}_view_test.rb",
- "#{PLUGIN_PATH}test/functional/#{m[1]}_controller_test.rb"]
- end
- at.add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
- if m[1] == "application" then
- combine_paths at, %r%^test/(controllers|views|functional)/.*_test\.rb$%
- else
- ["test/controllers/#{m[1]}_test.rb",
- "test/functional/#{m[1]}_test.rb",
- "#{PLUGIN_PATH}test/controllers/#{m[1]}_test.rb",
- "#{PLUGIN_PATH}test/functional/#{m[1]}_test.rb"]
- end
- end
- at.add_mapping %r%^app/views/layouts/% do
- ["test/views/layouts_view_test.rb", "#{PLUGIN_PATH}test/views/layouts_view_test.rb"]
- end
- at.add_mapping %r%^config/routes.rb$% do # FIX:
- combine_paths at, %r%^test/(controllers|views|functional)/.*_test\.rb$%
- end
- at.add_mapping %r%^test/test_helper.rb|config/((boot|environment(s/test)?).rb|database.yml)% do
- combine_paths at, %r%^test/(unit|controllers|views|functional)/.*_test\.rb$%
- end
- end
- def combine_paths(autotest_variable, regexp)
- results = []
- results << autotest_variable.files_matching(regexp)
- new_regexp = Regexp.new(regexp.to_s.gsub("^", "^#{PLUGIN_PATH}"))
- results << autotest_variable.files_matching(new_regexp)
- results.flatten
- end
Add Comment
Please, Sign In to add comment