Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use say_command

  • Loading branch information...
commit 3af22ce1fd074fc9018da2e415530a1d8201ea0a 1 parent 6d7c867
Gabe Berke-Williams gabebw authored
16 features/kumade_executable.feature
View
@@ -22,13 +22,13 @@ Feature: Kumade executable
"""
==> Git repo is clean
==> Packaged with Kumade::JammitPackager
- run git push origin master
+ git push origin master
==> Pushed master -> origin
- run git branch deploy
- run git push -f pretend-staging deploy:master
+ git branch deploy >/dev/null
+ git push -f pretend-staging deploy:master
==> Pushed deploy:master -> pretend-staging
==> Migrated pretend-staging
- run git checkout master && git branch -D deploy
+ git checkout master 2>/dev/null && git branch -D deploy
==> Deployed to: pretend-staging
"""
But the output should not contain "==> Packaged with Kumade::MorePackager"
@@ -53,13 +53,13 @@ Feature: Kumade executable
"""
==> Git repo is clean
==> Packaged with Kumade::JammitPackager
- run git push origin new_branch
+ git push origin new_branch
==> Pushed new_branch -> origin
- run git branch deploy
- run git push -f pretend-staging deploy:master
+ git branch deploy >/dev/null
+ git push -f pretend-staging deploy:master
==> Pushed deploy:master -> pretend-staging
==> Migrated pretend-staging
- run git checkout new_branch && git branch -D deploy
+ git checkout new_branch 2>/dev/null && git branch -D deploy
==> Deployed to: pretend-staging
"""
2  lib/kumade/command_line.rb
View
@@ -11,7 +11,7 @@ def run_or_error(error_message = nil)
end
def run_with_status
- Kumade.outputter.info(command)
+ Kumade.outputter.say_command(command)
Kumade.configuration.pretending? || run
end
5 lib/kumade/outputter.rb
View
@@ -12,5 +12,10 @@ def error(message)
puts "==> ! #{message}"
raise Kumade::DeploymentError, message
end
+
+ def say_command(command)
+ prefix = " " * 8
+ puts "#{prefix}#{command}"
+ end
end
end
4 spec/kumade/command_line_spec.rb
View
@@ -19,7 +19,7 @@
it "prints the command" do
subject.run_or_error
- Kumade.outputter.should have_received(:info).with(command_line.command).once
+ Kumade.outputter.should have_received(:say_command).with(command_line.command).once
end
end
@@ -59,7 +59,7 @@
it "prints the command" do
subject.run_with_status
- Kumade.outputter.should have_received(:info).with(command).once
+ Kumade.outputter.should have_received(:say_command).with(command).once
end
context "when pretending" do
2  spec/kumade/deployer_spec.rb
View
@@ -41,7 +41,7 @@
let(:new_branch) { 'new-branch' }
before do
- `git checkout -b #{new_branch}`
+ `git checkout -b #{new_branch} 2>/dev/null`
end
it "pushes the current branch to origin" do
18 spec/kumade/outputter_spec.rb
View
@@ -30,3 +30,21 @@
STDOUT.should have_received(:puts).with(regexp_matches(/==> the more you know/))
end
end
+
+describe Kumade::Outputter, "#say_command", :with_real_outputter => true do
+ before { STDOUT.stubs(:puts) }
+
+ it "prints a formatted message to STDOUT" do
+ subject.say_command("git checkout master")
+ STDOUT.should have_received(:puts).with(" " * 8 + "git checkout master")
+ end
+end
+
+describe Kumade::Outputter, "#info", :with_real_outputter => true do
+ before { STDOUT.stubs(:puts) }
+
+ it "prints a message to STDOUT" do
+ subject.info("the more you know")
+ STDOUT.should have_received(:puts).with(regexp_matches(/==> the more you know/))
+ end
+end
2  spec/spec_helper.rb
View
@@ -54,7 +54,7 @@ def remove_remote(remote_name)
end
else
@__real_outputter = Kumade.outputter unless Kumade.outputter.is_a?(Mocha::Mock)
- Kumade.outputter = stub("Null Outputter", :success => true, :error => true, :info => true)
+ Kumade.outputter = stub("Null Outputter", :success => true, :error => true, :info => true, :say_command => true)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.