Last active
June 26, 2021 05:55
-
-
Save ArturT/9b2fe6f3f39cd7914711 to your computer and use it in GitHub Desktop.
Watch file changes and run rspec for the test file or specified line number test. Use spring with rspec optionally.
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
# It requries installed nodemon | |
# $ npm install -g nodemon | |
# | |
# Add this in your ~/.bash_profile | |
# | |
# How to use it? | |
# | |
# Run spec for user_spec.rb when file changed. | |
# $ wr spec/models/user_spec.rb | |
# | |
# Run spec for user_spec.rb:80 (only spec in line 80) when file changed. | |
# $ wr spec/models/user_spec.rb 80 | |
# | |
# Use wsr if you want to run spring rspec to speed up. For instance: | |
# $ wsr spec/models/user_spec.rb 80 | |
function run_after_save { | |
prefix=$1 | |
file=$2 | |
line=$3 | |
if [ -z "$line" ]; then | |
nodemon -x "$prefix $file" -w "$file" | |
else | |
nodemon -x "$prefix $file:$line" -w "$file" | |
fi | |
} | |
alias wsr='run_after_save "bundle exec spring rspec"' | |
alias wr='run_after_save "bundle exec rspec"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment