Skip to content

Instantly share code, notes, and snippets.

@jhawthorn
Created February 7, 2017 21:43
Show Gist options
  • Save jhawthorn/bc9adb2eb91651c6a0ba5c0b787c8014 to your computer and use it in GitHub Desktop.
Save jhawthorn/bc9adb2eb91651c6a0ba5c0b787c8014 to your computer and use it in GitHub Desktop.
set -e
git_changed() {
changes=$(git diff)
[ -n "$changes" ]
}
find spec -name '*_spec.rb' | xargs sed -i 's/spree_\(get\|post\|put\|delete\)/\1/g'
if git_changed; then
git commit -am 'Use normal get/post/put/delete test helpers' || true
fi
rails5-spec-converter
if git_changed; then
sed -i '/rails-controller-testing/ a else\n gem "rails_test_params_backport"' Gemfile
git commit -am 'Use rails 5 request test syntax' || true
sed -i '/rails_test_params_backport/ a \ \ gem "rails", "~> 4.2.7"' Gemfile
git commit -am 'Specify rails 4.2 version (bundler workaround)' || true
else
sed -i '/rails-controller-testing/ a else\n gem "rails", "~> 4.2.7"' Gemfile
git commit -am 'Specify rails 4.2 version (bundler workaround)' || true
fi
@jhawthorn
Copy link
Author

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