Skip to content

Instantly share code, notes, and snippets.

@equivalent
Created November 11, 2011 12:20
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 equivalent/1357875 to your computer and use it in GitHub Desktop.
Save equivalent/1357875 to your computer and use it in GitHub Desktop.
This is a bash script that runs bundler, drop test database, recreates it, run migrations and runs specs and tests
#!/bin/sh
WORK_DIR=/Users/tomi/rails_apps/myapp/;
RETURN_DIR=/Users/tomi/my_bash_scripts/; #optional
if [ -r $WORK_DIR ]; then
cd $WORK_DIR
echo "Changing directory to $WORK_DIR"
#ls -l;
# if [ -f ./.rvmrc ]; then
# . ./.rvmrc
# fi
rvm current
read -p "Is this RVM version ok ? Press any key to start continue..."
bundle install; #install gems
RAILS_ENV=test bundle exec rake db:drop;
RAILS_ENV=test bundle exec rake db:create;
RAILS_ENV=test bundle exec rake db:migrate;
bundle exec rspec spec;
RAILS_ENV=developmnet bundle exec rake db:migrate; #rake requires that development enviroment has database updated to run unit tests, comment this if you don't want this feature
bundle exec rake test;
if [ -r $RETURN_DIR ]; then
echo "Changing directory back to $RETURN_DIR"
cd $RETURN_DIR;
fi
else
echo "Work Directory doesn't exist"
fi
### bash alias for this script add it into your ~/.bash_profile or ~/.bash_profile ###
### you might need to do chmod 755 /Users/tomi/my_bash_scripts/run_rails_app_tests.sh ###
# alias run_app_tests='/Users/tomi/my_bash_scripts/run_rails_app_tests.sh'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment