如果我的测试套件通过,我该如何编写将部署到Heroku的rake脚本?
我正在使用Minitest测试,现在我的Rakefile的相关部分看起来像这样:
task :test do
$LOAD_PATH.unshift('tests')
Dir.glob('./tests/spec_*.rb').each { |file| require file}
Dir.glob('./tests/test_*.rb').each { |file| require file}
end
task :deploy do
sh "git push heroku master"
end
答案 0 :(得分:1)
当minitests'测试失败rake返回退出代码1,所以如果你从capistrano任务调用测试并检查退出代码,你可以退出脚本。
namespace :deploy do
desc "Runs test before deploying, can't deploy unless they pass"
task :tests do
puts "--> Running tests, please wait ..."
unless system "RAILS_ENV=test bundle exec rake"
puts "Tests failed"
exit 1
else
puts "Tests passed"
end
end
end