Skip to content

Instantly share code, notes, and snippets.

@ChunAllen
Created January 10, 2018 11:29
Show Gist options
  • Save ChunAllen/8b8e8a3e539e9b8d00f248e675fad089 to your computer and use it in GitHub Desktop.
Save ChunAllen/8b8e8a3e539e9b8d00f248e675fad089 to your computer and use it in GitHub Desktop.
Running rake test on local before deploying using capistrano
namespace :deploy do
desc "Runs test before deploying, can't deploy unless they pass"
task :run_tests do
puts "--> Running tests, please wait ..."
test_log = "log/capistrano.log"
unless system "bundle exec rake > #{test_log} 2>&1" #' > /dev/null'
puts "--> Tests failed. Run `cat #{test_log}` to see what went wrong."
exit
else
puts "--> Tests passed"
system "rm #{test_log}"
end
end
end
before :deploy, "deploy:run_tests"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment