diff options
author | Brian D. Burns <burns@iosctr.com> | 2013-01-15 13:56:10 -0500 |
---|---|---|
committer | Brian D. Burns <burns@iosctr.com> | 2013-01-15 14:14:05 -0500 |
commit | 5a9b3b7a74e5b284312d69c8fd7a6fd3167f6dad (patch) | |
tree | b471bd95a0f6a05dd4d5efe1459415709c37e436 /railties/test/application | |
parent | 7fff04f4e8a5fcb8081adeeb81bbd7f866ac07ee (diff) | |
download | rails-5a9b3b7a74e5b284312d69c8fd7a6fd3167f6dad.tar.gz rails-5a9b3b7a74e5b284312d69c8fd7a6fd3167f6dad.tar.bz2 rails-5a9b3b7a74e5b284312d69c8fd7a6fd3167f6dad.zip |
allow :dirs option for .enumerate
Allows custom rake tasks to be defined using:
SourceAnnotationExtractor.enumerate 'TODO|FIXME', dirs: %w(app lib), tag: true
Diffstat (limited to 'railties/test/application')
-rw-r--r-- | railties/test/application/rake/notes_test.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/railties/test/application/rake/notes_test.rb b/railties/test/application/rake/notes_test.rb index 5893d58925..3508f4225a 100644 --- a/railties/test/application/rake/notes_test.rb +++ b/railties/test/application/rake/notes_test.rb @@ -130,6 +130,45 @@ module ApplicationTests end end + test 'custom rake task finds specific notes in specific directories' do + app_file "app/controllers/some_controller.rb", "# TODO: note in app directory" + app_file "lib/some_file.rb", "# OPTIMIZE: note in lib directory\n" << "# FIXME: note in lib directory" + app_file "test/some_test.rb", 1000.times.map { "" }.join("\n") << "# TODO: note in test directory" + + app_file "lib/tasks/notes_custom.rake", <<-EOS + require 'rails/source_annotation_extractor' + task :notes_custom do + tags = 'TODO|FIXME' + opts = { dirs: %w(lib test), tag: true } + SourceAnnotationExtractor.enumerate(tags, opts) + end + EOS + + boot_rails + + require 'rake' + require 'rdoc/task' + require 'rake/testtask' + + Rails.application.load_tasks + + Dir.chdir(app_path) do + output = `bundle exec rake notes_custom` + lines = output.scan(/\[([0-9\s]+)\]/).flatten + + assert_match(/\[FIXME\] note in lib directory/, output) + assert_match(/\[TODO\] note in test directory/, output) + assert_no_match(/OPTIMIZE/, output) + assert_no_match(/note in app directory/, output) + + assert_equal 2, lines.size + + lines.each do |line_number| + assert_equal 4, line_number.size + end + end + end + private def boot_rails super |