Skip to content

Instantly share code, notes, and snippets.

@elchingon
Created October 20, 2017 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elchingon/c83a37e493cd207e32696a8c5d2e0126 to your computer and use it in GitHub Desktop.
Save elchingon/c83a37e493cd207e32696a8c5d2e0126 to your computer and use it in GitHub Desktop.
#!/bin/bash
# get a list of files which contain "require" AND "spec_helper" on a single line
# excluding spec/rails_helper.rb (we want "require 'spec_helper'" to exist here)
declare -a files=$(git grep -E "require.*spec_helper" | cut -d ':' -f 1 | grep -v 'spec/rails_helper.rb')
# loop through files and replace "spec_helper" with "rails_helper"
for i in $files; do
sed -i '' -e 's/spec_helper/rails_helper/' $i
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment