-
-
Save chmurph2/a935d44f924f0d8fca78 to your computer and use it in GitHub Desktop.
Bash function to run targeted Rails tests.
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
# Use: rt test_file | |
# Use: rt test_file:test_name_regex | |
# Finds a file under test/* and runs it with -n /test_name_regex/ | |
function rt { | |
FILE_HINT=`echo $1 | cut -f1 -d:` | |
TEST_REGEX=`echo $1 | cut -f2 -d:` | |
FILE_PATH=`find test/* -maxdepth 3 -name ${FILE_HINT}_test.rb` | |
if [ -z $FILE_PATH ]; | |
then | |
echo Couldn\'t find file for $FILE_HINT | |
return | |
fi | |
if [[ $1 =~ ":" ]]; | |
then | |
echo Running $FILE_PATH -n /$TEST_REGEX/ | |
ruby -Itest $FILE_PATH -n /$TEST_REGEX/ | |
else | |
echo Running $FILE_PATH | |
ruby -Itest $FILE_PATH | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment