public
Last active

This is a bash script that runs bundler, drop test database, recreates it, run migrations and runs specs and tests

  • Download Gist
run_rails_app_tests.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
#!/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'

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.