Skip to content

Instantly share code, notes, and snippets.

@rossmari
Created July 4, 2014 08:08
Show Gist options
  • Save rossmari/413a4ba1a3ffc2f15d80 to your computer and use it in GitHub Desktop.
Save rossmari/413a4ba1a3ffc2f15d80 to your computer and use it in GitHub Desktop.
task to start rspec before deploy
desc 'Start rspec before deploy'
task :rspec, :roles => :app do
puts 'Starting rspec examples ... prepare to be punished!'
output = %x[bundle exec rspec]
respond = output.split(/\n/)
if respond.any? { |e| e.match(/Failures:/)}
set(:confirmed) do
puts "\n\t#{'='*75}\n\n\tThere are errors:\n\n\t>>> #{respond.detect { |e| e.match(/.*failure.*/) }.upcase}\n\n\t#{'='*75}\n"
Capistrano::CLI.ui.ask("\n\tAre you sure you want to continue? (Y) ") == 'Y' ? true : false
end
unless fetch(:confirmed)
puts "\nDeploy canceled!"
exit
end
else
puts 'All tests are done! Lets rock baby!'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment