mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Extract rake notes command and lines scan boilerplate
Refactor to a reusable method.
This commit is contained in:
parent
3a3a386d4f
commit
9c5c0bcfa6
1 changed files with 14 additions and 19 deletions
|
@ -31,10 +31,7 @@ module ApplicationTests
|
||||||
boot_rails
|
boot_rails
|
||||||
load_tasks
|
load_tasks
|
||||||
|
|
||||||
Dir.chdir(app_path) do
|
run_rake_notes do |output, lines|
|
||||||
output = `bundle exec rake notes`
|
|
||||||
lines = output.scan(/\[([0-9\s]+)\]\s/).flatten
|
|
||||||
|
|
||||||
assert_match(/note in erb/, output)
|
assert_match(/note in erb/, output)
|
||||||
assert_match(/note in js/, output)
|
assert_match(/note in js/, output)
|
||||||
assert_match(/note in css/, output)
|
assert_match(/note in css/, output)
|
||||||
|
@ -64,10 +61,7 @@ module ApplicationTests
|
||||||
boot_rails
|
boot_rails
|
||||||
load_tasks
|
load_tasks
|
||||||
|
|
||||||
Dir.chdir(app_path) do
|
run_rake_notes do |output, lines|
|
||||||
output = `bundle exec rake notes`
|
|
||||||
lines = output.scan(/\[([0-9\s]+)\]/).flatten
|
|
||||||
|
|
||||||
assert_match(/note in app directory/, output)
|
assert_match(/note in app directory/, output)
|
||||||
assert_match(/note in config directory/, output)
|
assert_match(/note in config directory/, output)
|
||||||
assert_match(/note in db directory/, output)
|
assert_match(/note in db directory/, output)
|
||||||
|
@ -95,10 +89,7 @@ module ApplicationTests
|
||||||
boot_rails
|
boot_rails
|
||||||
load_tasks
|
load_tasks
|
||||||
|
|
||||||
Dir.chdir(app_path) do
|
run_rake_notes "SOURCE_ANNOTATION_DIRECTORIES='some_other_dir' bundle exec rake notes" do |output, lines|
|
||||||
output = `SOURCE_ANNOTATION_DIRECTORIES='some_other_dir' bundle exec rake notes`
|
|
||||||
lines = output.scan(/\[([0-9\s]+)\]/).flatten
|
|
||||||
|
|
||||||
assert_match(/note in app directory/, output)
|
assert_match(/note in app directory/, output)
|
||||||
assert_match(/note in config directory/, output)
|
assert_match(/note in config directory/, output)
|
||||||
assert_match(/note in db directory/, output)
|
assert_match(/note in db directory/, output)
|
||||||
|
@ -132,10 +123,7 @@ module ApplicationTests
|
||||||
boot_rails
|
boot_rails
|
||||||
load_tasks
|
load_tasks
|
||||||
|
|
||||||
Dir.chdir(app_path) do
|
run_rake_notes "bundle exec rake notes_custom" do |output, lines|
|
||||||
output = `bundle exec rake notes_custom`
|
|
||||||
lines = output.scan(/\[([0-9\s]+)\]/).flatten
|
|
||||||
|
|
||||||
assert_match(/\[FIXME\] note in lib directory/, output)
|
assert_match(/\[FIXME\] note in lib directory/, output)
|
||||||
assert_match(/\[TODO\] note in test directory/, output)
|
assert_match(/\[TODO\] note in test directory/, output)
|
||||||
assert_no_match(/OPTIMIZE/, output)
|
assert_no_match(/OPTIMIZE/, output)
|
||||||
|
@ -157,9 +145,7 @@ module ApplicationTests
|
||||||
boot_rails
|
boot_rails
|
||||||
load_tasks
|
load_tasks
|
||||||
|
|
||||||
Dir.chdir(app_path) do
|
run_rake_notes do |output, lines|
|
||||||
output = `bundle exec rake notes`
|
|
||||||
lines = output.scan(/\[([0-9\s]+)\]/).flatten
|
|
||||||
assert_match(/note in scss/, output)
|
assert_match(/note in scss/, output)
|
||||||
assert_match(/note in sass/, output)
|
assert_match(/note in sass/, output)
|
||||||
assert_equal 2, lines.size
|
assert_equal 2, lines.size
|
||||||
|
@ -168,6 +154,15 @@ module ApplicationTests
|
||||||
|
|
||||||
private
|
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
|
def load_tasks
|
||||||
require 'rake'
|
require 'rake'
|
||||||
require 'rdoc/task'
|
require 'rdoc/task'
|
||||||
|
|
Loading…
Reference in a new issue