Is there a way to have capistrano run unit tests on my Rails app when I run cap deploy
, and fail if they don't pass? I know this can and should be done by the deployer, but I'd love it to be automatic. Any ideas would be greatly appreciated.
Thanks in advance!
EDIT: I ended up using this as a solution.
This capistrano task will run the unit tests on the server being deployed, in production mode:
desc "Run the full tests on the deployed app."
task :run_tests do
run "cd #{release_path} && RAILS_ENV=production rake && cat /dev/null > log/test.log"
end
Found the solution here: http://marklunds.com/articles/one/338
:D
This setup will run your tests locally before deploying.
Capistrano task, e.g. lib/capistrano/tasks/deploy.rake
namespace :deploy do
desc 'Run test suite before deployment'
task :test_suite do
run_locally do
execute :rake, 'test'
end
end
end
Capistrano config, config/deploy.rb
before 'deploy:starting', 'deploy:test_suite'
Works in Capistrano v3.x
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With