spec/tasks_spec.rb in slackistrano-0.1.12 vs spec/tasks_spec.rb in slackistrano-1.0.0

- old
+ new

@@ -3,29 +3,38 @@ describe Slackistrano do before(:each) do Rake::Task['load:defaults'].invoke end - it "invokes slack:deploy:starting after deploy:starting" do - set :slack_run_starting, ->{ true } - expect(Slackistrano).to receive :post - Rake::Task['deploy:starting'].execute - end + describe "before/after hooks" do - it "invokes slack:deploy:finished after deploy:finished" do - set :slack_run_finished, ->{ true } - expect(Slackistrano).to receive :post - Rake::Task['deploy:finished'].execute - end + it "invokes slack:deploy:updating before deploy:updating" do + expect(Rake::Task['deploy:updating'].prerequisites).to include 'slack:deploy:updating' + end - it "invokes slack:deploy:failed after deploy:failed" do - set :slack_run_failed, ->{ true } - expect(Slackistrano).to receive :post - Rake::Task['deploy:failed'].execute + it "invokes slack:deploy:reverting before deploy:reverting" do + expect(Rake::Task['deploy:reverting'].prerequisites).to include 'slack:deploy:reverting' + end + + it "invokes slack:deploy:updated after deploy:finishing" do + expect(Rake::Task['slack:deploy:updated']).to receive(:invoke) + Rake::Task['deploy:finishing'].execute + end + + it "invokes slack:deploy:reverted after deploy:finishing_rollback" do + expect(Rake::Task['slack:deploy:reverted']).to receive(:invoke) + Rake::Task['deploy:finishing_rollback'].execute + end + + it "invokes slack:deploy:failed after deploy:failed" do + expect(Rake::Task['slack:deploy:failed']).to receive(:invoke) + Rake::Task['deploy:failed'].execute + end + end - %w[starting finished failed].each do |stage| + %w[updating reverting updated reverted failed].each do |stage| it "posts to slack on slack:deploy:#{stage}" do set "slack_run_#{stage}".to_sym, ->{ true } expect(Slackistrano).to receive :post Rake::Task["slack:deploy:#{stage}"].execute end @@ -36,14 +45,17 @@ Rake::Task["slack:deploy:#{stage}"].execute end end [ # stage, color, channel - ['starting', nil, nil], - ['finished', 'good', nil], + ['updating', nil, nil], + ['reverting', nil, nil], + ['updated', 'good', nil], + ['reverted', '#4CBDEC', nil], ['failed', 'danger', nil], - ['starting', nil, 'starting_channel'], - ['finished', 'good', 'finished_channel'], + ['updating', nil, 'starting_channel'], + ['updated', 'good', 'finished_channel'], + ['reverted', '#4CBDEC', 'rollback_channel'], ['failed', 'danger', 'failed_channel'], ].each do |stage, color, channel_for_stage| it "calls Slackistrano.post with the right arguments for stage=#{stage}, color=#{color}, channel_for_stage=#{channel_for_stage}" do set :"slack_run_#{stage}", -> { true }