Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Owner

travisofthenorth commented Jun 19, 2016

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