Skip to content

Instantly share code, notes, and snippets.

@lulalala
Created November 2, 2012 09:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lulalala/3999775 to your computer and use it in GitHub Desktop.
Save lulalala/3999775 to your computer and use it in GitHub Desktop.
rspec with grep to run selected specs
function rspecgrep()
{
SPK_FILES=`find spec -type f -name "*_spec.rb" | grep $1`
echo $SPK_FILES
time rspec $SPK_FILES --format documentation
}
@ThomBian
Copy link

ThomBian commented Oct 8, 2018

This code helped me a lot thanks for the helper.
However, it looks like it's deprecated because it fails whenever you try to execute it. The main reason is that $SPK_FILLES seems to be treated as a string by rspec.
Here is my patch to make it work properly.

#!/bin/(shell of your choice)
function rspecgrep()
{
  SPK_FILES=`find spec -type f -name "*_spec.rb" | grep $1`
  echo $(echo "${SPK_FILES}" | sed -e 's/\n/\\n/' -e 's/ /\ /')
  time rspec --format documentation -- $(echo "${SPK_FILES}" | sed -e 's/\n/\\n/' -e 's/ /\ /')
}

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