Created
June 4, 2014 20:23
-
-
Save tomkadwill/f427a67545f48f49593a to your computer and use it in GitHub Desktop.
Fast Ruby Specs
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
#!/bin/bash | |
set -e | |
need_rails=1 | |
if [ $# -gt 0 ]; then # we have args | |
filename=$1 | |
# remove trailing line numbers from filename, e.g. spec/my_spec.rb:33 | |
grep_filename=`echo $1 | sed 's/:.*$//g'` | |
(set +e; grep -r 'spec_helper' $grep_filename) > /dev/null | |
if [ $? -eq 1 ]; then # no match; we have a stand-alone spec | |
need_rails='' | |
fi | |
else | |
filename='spec' | |
fi | |
command='rspec' | |
if [ $need_rails ]; then | |
command="ruby -S bundle exec $command" | |
fi | |
RAILS_ENV=test $command $filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment