Watch file changes with nodemon and run rspec for the test file or specified line number test. Use spring with rspec optionally.
$ npm install -g nodemon
~/.bash_profile
~/.zshrc
$ wr spec/models/user_spec.rb
$ wr spec/models/user_spec.rb 80
$ 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"'