Permalink
Browse files

Remove multistage dependency

  • Loading branch information...
1 parent 1c21389 commit e3f7fe6898cfece3d930c5c45ed9e05a9250d99d @iain committed Apr 5, 2012
Showing with 30 additions and 8 deletions.
  1. +0 −2 README.md
  2. +16 −6 lib/capistrano/blaze.rb
  3. +14 −0 spec/camp_spec.rb
View
@@ -50,8 +50,6 @@ $ cap campfire:test_config
## Todo
* Configure what kinds of messages are displayed
-* Don't depend on the multistage extension
-* Centralize configuration via a `~/.blazerc` or something...
## Contributing
@@ -35,21 +35,31 @@ def speak(message)
end
def failure(context, exception)
- speak ":warning: #{user} failed to deploy to the #{context.stage} stage of #{context.application}, via `#{command}`: #{exception.to_s} (#{exception.class.inspect})"
+ speak ":warning: #{user} failed to deploy #{stage(context)}#{context.application}, via `#{command}`: #{exception.to_s} (#{exception.class.inspect})"
end
def success(context)
- speak "#{user} succesfully deployed to the #{context.stage} stage of #{context.application}, via `#{command}`"
- end
-
- def user
- `whoami`.strip
+ speak "#{user} succesfully deployed #{stage(context)}#{context.application}, via `#{command}`"
end
def test(context)
speak ":heart: #{context.application}!"
end
+ private
+
+ def stage(context)
+ if context.respond_to?(:stage)
+ "to the #{context.stage} stage of "
+ else
+ ""
+ end
+ end
+
+ def user
+ `whoami`.strip
+ end
+
def command
[ 'cap', *$* ] * ' '
end
View
@@ -46,4 +46,18 @@
subject.test(context)
end
+ it "displays success message without a stage" do
+ subject.should_receive(:speak).with("iain succesfully deployed basecamp, via `cap #{ARGV.join(' ')}`")
+ 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)")
+ context = stub(:application => "basecamp")
+ exception = RuntimeError.new("woops")
+ subject.failure(context, exception)
+ end
+
+
end

0 comments on commit e3f7fe6

Please sign in to comment.