Skip to content

Instantly share code, notes, and snippets.

@travisofthenorth
Last active September 28, 2017 20:04
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 travisofthenorth/4c88c0e6db5db61153607d652237582c to your computer and use it in GitHub Desktop.
Save travisofthenorth/4c88c0e6db5db61153607d652237582c to your computer and use it in GitHub Desktop.
If you're using FactoryGirl, replace all occurrences of 'create' with 'build' and 'git add' the specs that still pass.
#!/bin/bash
find spec -iname "*spec.rb" -exec sed -i.bak 's/create/build/g' {} \;
find spec -iname "*spec.rb" -print0 | while IFS= read -r -d $'\0' spec; do
spring rspec $spec --fail-fast
if [[ $? -gt 0 ]]; then
echo "$spec did not pass"
else
echo "$spec passed!!!"
git add $spec
fi
done
@travisofthenorth
Copy link
Author

If you use parentheses, e.g. create(:thing), you can make the sed command a little more reliable by including a few extra characters:
find spec -iname "*spec.rb" -exec sed -i.bak 's/create(:/build(:/g' {} \;

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