diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2014-03-17 21:04:18 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2014-03-19 21:47:38 -0300 |
commit | 9c5c0bcfa6d81d45ef091dc8740623faa5e19784 (patch) | |
tree | dd3d1da4f748605d799b1213b28a2a39c8d3b8a2 /railties | |
parent | 3a3a386d4f6667c606fabdcb53c325e9d531d358 (diff) | |
download | rails-9c5c0bcfa6d81d45ef091dc8740623faa5e19784.tar.gz rails-9c5c0bcfa6d81d45ef091dc8740623faa5e19784.tar.bz2 rails-9c5c0bcfa6d81d45ef091dc8740623faa5e19784.zip |
Extract rake notes command and lines scan boilerplate
Refactor to a reusable method.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/test/application/rake/notes_test.rb | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/railties/test/application/rake/notes_test.rb b/railties/test/application/rake/notes_test.rb index 10e0d2568c..23eb4c9939 100644 --- a/railties/test/application/rake/notes_test.rb +++ b/railties/test/application/rake/notes_test.rb @@ -31,10 +31,7 @@ module ApplicationTests boot_rails load_tasks - Dir.chdir(app_path) do - output = `bundle exec rake notes` - lines = output.scan(/\[([0-9\s]+)\]\s/).flatten - + run_rake_notes do |output, lines| assert_match(/note in erb/, output) assert_match(/note in js/, output) assert_match(/note in css/, output) @@ -64,10 +61,7 @@ module ApplicationTests boot_rails load_tasks - Dir.chdir(app_path) do - output = `bundle exec rake notes` - lines = output.scan(/\[([0-9\s]+)\]/).flatten - + run_rake_notes do |output, lines| assert_match(/note in app directory/, output) assert_match(/note in config directory/, output) assert_match(/note in db directory/, output) @@ -95,10 +89,7 @@ module ApplicationTests boot_rails load_tasks - Dir.chdir(app_path) do - output = `SOURCE_ANNOTATION_DIRECTORIES='some_other_dir' bundle exec rake notes` - lines = output.scan(/\[([0-9\s]+)\]/).flatten - + run_rake_notes "SOURCE_ANNOTATION_DIRECTORIES='some_other_dir' bundle exec rake notes" do |output, lines| assert_match(/note in app directory/, output) assert_match(/note in config directory/, output) assert_match(/note in db directory/, output) @@ -132,10 +123,7 @@ module ApplicationTests boot_rails load_tasks - Dir.chdir(app_path) do - output = `bundle exec rake notes_custom` - lines = output.scan(/\[([0-9\s]+)\]/).flatten - + run_rake_notes "bundle exec rake notes_custom" do |output, lines| assert_match(/\[FIXME\] note in lib directory/, output) assert_match(/\[TODO\] note in test directory/, output) assert_no_match(/OPTIMIZE/, output) @@ -157,9 +145,7 @@ module ApplicationTests boot_rails load_tasks - Dir.chdir(app_path) do - output = `bundle exec rake notes` - lines = output.scan(/\[([0-9\s]+)\]/).flatten + run_rake_notes do |output, lines| assert_match(/note in scss/, output) assert_match(/note in sass/, output) assert_equal 2, lines.size @@ -168,6 +154,15 @@ module ApplicationTests private + def run_rake_notes(command = 'bundle exec rake notes') + Dir.chdir(app_path) do + output = `#{command}` + lines = output.scan(/\[([0-9\s]+)\]\s/).flatten + + yield output, lines + end + end + def load_tasks require 'rake' require 'rdoc/task' |