Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "start" recipe and before deploy hook #1

Merged
merged 1 commit into from Apr 5, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rvmrc
@@ -1 +1 @@
rvm 1.9.3@capistrano-blaze
rvm 1.9.3-p125@capistrano-blaze
4 changes: 4 additions & 0 deletions lib/capistrano/blaze.rb
Expand Up @@ -34,6 +34,10 @@ def speak(message)
end
end

def start(context)
speak "#{user} is deploying #{stage(context)}#{context.application}, via `#{command}`"
end

def failure(context, exception)
speak ":warning: #{user} failed to deploy #{stage(context)}#{context.application}, via `#{command}`: #{exception.to_s} (#{exception.class.inspect})"
end
Expand Down
5 changes: 5 additions & 0 deletions lib/capistrano/blaze/recipes.rb
Expand Up @@ -8,6 +8,10 @@

namespace :campfire do

task :start do
Capistrano::Blaze.start(self)
end

task :success do
Capistrano::Blaze.success(self)
end
Expand All @@ -19,6 +23,7 @@

end

before "deploy", "campfire:start"
after "deploy:restart", "campfire:success"

end
17 changes: 13 additions & 4 deletions spec/camp_spec.rb
Expand Up @@ -27,15 +27,21 @@
subject.stub(:user) { "iain" }
end

it "displays a start message" do
subject.should_receive(:speak).with("iain is deploying to the production stage of basecamp, via `#{command}`")
context = stub(:stage => "production", :application => "basecamp")
subject.start(context)
end

it "displays a failure message" do
subject.should_receive(:speak).with(":warning: iain failed to deploy to the production stage of basecamp, via `cap #{ARGV.join(' ')}`: woops (RuntimeError)")
subject.should_receive(:speak).with(":warning: iain failed to deploy to the production stage of basecamp, via `#{command}`: woops (RuntimeError)")
context = stub(:stage => "production", :application => "basecamp")
exception = RuntimeError.new("woops")
subject.failure(context, exception)
end

it "displays success message" do
subject.should_receive(:speak).with("iain succesfully deployed to the production stage of basecamp, via `cap #{ARGV.join(' ')}`")
subject.should_receive(:speak).with("iain succesfully deployed to the production stage of basecamp, via `#{command}`")
context = stub(:stage => "production", :application => "basecamp")
subject.success(context)
end
Expand All @@ -47,17 +53,20 @@
end

it "displays success message without a stage" do
subject.should_receive(:speak).with("iain succesfully deployed basecamp, via `cap #{ARGV.join(' ')}`")
subject.should_receive(:speak).with("iain succesfully deployed basecamp, via `#{command}`")
context = stub(:application => "basecamp")
subject.success(context)
end

it "displays failure message without a stage" do
subject.should_receive(:speak).with(":warning: iain failed to deploy basecamp, via `cap #{ARGV.join(' ')}`: woops (RuntimeError)")
subject.should_receive(:speak).with(":warning: iain failed to deploy basecamp, via `#{command}`: woops (RuntimeError)")
context = stub(:application => "basecamp")
exception = RuntimeError.new("woops")
subject.failure(context, exception)
end

def command
[ 'cap', ARGV ].flatten * ' '
end

end