Last active
August 29, 2015 14:25
-
-
Save coen-hyde/721d12160eaae3082a7e to your computer and use it in GitHub Desktop.
Add this snippet to you bash profile to give you the power of beer.
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
ROOT_PROJECT_DIR=$HOME/projects/ | |
proot() { | |
echo $(echo $PWD | sed "s|\($ROOT_PROJECT_DIR[A-Za-z]*\).*|\1|") | |
} | |
beer() { | |
spec=$1 | |
shift | |
cd $(proot); bundle exec rspec ./spec/$spec $@ | |
} | |
_beer_completion() { | |
COMPREPLY=($(compgen -W "$(cd $(proot); find ./spec -type f | sed 's|./spec/||')" ${COMP_WORDS[COMP_CWORD]})) | |
} | |
complete -F _beer_completion beer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That is a short hand for
bundle exec rspec
with auto complete scoped to $project_root/specs. It can be run within any folder of the current project. ie while in $project_root/app/controllers, runningbeer controllers/tracker2/activities_controller_spec.rb
is the equivalent ofcd $project_root; bundle exec rspec specs/controllers/tracker2/activities_controller_spec.rb