Skip to content

Commit

Permalink
Update .rvmrc to use Ruby p125. Add "start" recipe and before deploy …
Browse files Browse the repository at this point in the history
…hook. Green specs
  • Loading branch information
marceldegraaf committed Apr 5, 2012
1 parent 90f4617 commit dae74f1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
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

0 comments on commit dae74f1

Please sign in to comment.