Created
December 24, 2010 19:15
-
-
Save semanticart/754459 to your computer and use it in GitHub Desktop.
search the test files for a phrase and run the tests that match
This file contains 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
# you'll probably want to alias this in one of your dotfiles | |
# i.e. alias st="ruby -I\"lib:test\" search_and_test.rb" | |
# | |
# the -I"lib:test" can be important if you get complaints like "no such file to load -- test_helper (MissingSourceFile)" | |
ack_opts = [ | |
"-i", # case insensitive | |
"-l", # just return file names | |
"-G _test.rb", # only search files whose name matches /_test.rb/ | |
ARGV.join(' '), # pass along any options we're passed in (usually just the search string) | |
"test/" # scope our search to the test directory | |
].join(" ") | |
test_files = `ack #{ack_opts}`.split("\n") | |
if test_files.size > 0 | |
puts "Testing: #{test_files.join(" ")}" | |
test_files.each do |file| | |
load file | |
end | |
else | |
puts "No matches for #{ARGV.join(" ")}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment