Skip to content

Instantly share code, notes, and snippets.

@addywaddy
Forked from fronx/git_spec_aliases.sh
Created January 5, 2012 09:54
Show Gist options
  • Save addywaddy/1564495 to your computer and use it in GitHub Desktop.
Save addywaddy/1564495 to your computer and use it in GitHub Desktop.
# list all changed spec files
alias d_specs='git diff --name-only | grep _spec.rb|sed -E "s/(.*)/\.\/\1/"'
# list all changed *.rb filenames without path and extension
alias diffrb='git diff --name-only|xargs basename -s .rb'
# diffrb.map { |s| "#{s}_spec"}.join('|')
alias any_diffrb="diffrb | tr '\n' '|'|sed -E \"s/^(.*).$/\1_spec/\""
# list all spec files that correspond to changed *.rb files (assuming they share the same prefix)
alias d_specs_more='find ./spec -name *_spec.rb|grep -E "(`any_diffrb`)"'
# find a spec by path-less name
function find_spec() {
find ./spec -name *_spec.rb|grep -E "$@";
}
# run a spec by path-less name
function fspec() {
find_spec "$@";
spec `find_spec "$@"`;
}
# list all in/directly changed specs
alias d_specs_all='d_specs_more|sort|uniq'
# run all specs that are changed or whose corresponding implementations have changed
alias dspec='d_specs_all; spec `d_specs_all`'
@addywaddy
Copy link
Author

Should give you the same result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment