Last Updated: February 25, 2016
·
659
· gurix

Just run rspec tests that differ from master

Imagine you started a branch and you would not test everything before you are done, you are just interested in the tests you added or modified. The following piece of code runs rspec just for these files.

git diff --name-only --diff-filter=AMR origin/master  | grep _spec.rb | xargs rspec

... make an alias ...

echo "alias mspec='git diff --name-only --diff-filter=AMR origin/master  | grep _spec.rb | xargs rspec'" >> ~/.bashrc

... and whenever you are working in a branch, you can just type mspec to run your modified tests.