#!/usr/bin/env bash

if [[ $# -ne 1 ]]; then
  echo "Usage: $0 <smart-answer-flow-name>"
  exit
fi

if [[ -n "$(git status --porcelain)" ]]; then
  echo "Please run with a clean git working directory"
  exit
fi

bundle install

bundle exec rails runner script/generate-responses-and-expected-results-for-smart-answer.rb $1

if [[ -n "$(git status --porcelain)" ]]; then
  git add test/data/$1-responses-and-expected-results.yml
  git commit -m "Update expected results for $1"
fi

RUN_REGRESSION_TESTS=$1 ruby test/regression/smart_answers_regression_test.rb

if [[ -n "$(git status --porcelain)" ]]; then
  git add test/artefacts/$1
  git commit -m "Update test artefacts for $1"
fi

RUN_REGRESSION_TESTS=$1 ruby test/regression/smart_answers_regression_test.rb

#!/usr/bin/env bash

if [[ $# -ne 1 ]]; then
  echo "Usage: $0 <smart-answer-flow-name>"
  exit
fi

if [[ -n "$(git status --porcelain)" ]]; then
  echo "Please run with a clean git working directory"
  exit
fi

bundle install

bundle exec rails runner script/generate-responses-and-expected-results-for-smart-answer.rb $1

if [[ -n "$(git status --porcelain)" ]]; then
  git add test/data/$1-responses-and-expected-results.yml
  git commit -m "Update expected results for $1"
fi

RUN_REGRESSION_TESTS=$1 bundle exec ruby test/regression/smart_answers_regression_test.rb

if [[ -n "$(git status --porcelain)" ]]; then
  git add test/artefacts/$1
  git commit -m "Update test artefacts for $1"
fi

RUN_REGRESSION_TESTS=$1 bundle exec ruby test/regression/smart_answers_regression_test.rb

Update PR prep script to internalise `bundle exec`
Update PR prep script to internalise `bundle exec`

This means you won't need to run the whole thing under `bundle exec` manually.

Co-authored-by: Alan Gabbianelli <321a17de59cb78c00db7c6549ce3de7e3ef94655@digital.cabinet-office.gov.uk>
