Skip to content

Instantly share code, notes, and snippets.

@fronx
Created March 28, 2011 16:21
Show Gist options
  • Save fronx/890763 to your computer and use it in GitHub Desktop.
Save fronx/890763 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|grep "\/[^/\.]*\.rb$" -o |grep -v _spec|cut -d . -f 1'
# 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`'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment