Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
Use say_command
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabe Berke-Williams committed Oct 14, 2011
1 parent 6d7c867 commit 3af22ce
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 13 deletions.
16 changes: 8 additions & 8 deletions features/kumade_executable.feature
Expand Up @@ -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"
Expand All @@ -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
"""

Expand Down
2 changes: 1 addition & 1 deletion lib/kumade/command_line.rb
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions lib/kumade/outputter.rb
Expand Up @@ -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 changes: 2 additions & 2 deletions spec/kumade/command_line_spec.rb
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/kumade/deployer_spec.rb
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions spec/kumade/outputter_spec.rb
Expand Up @@ -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 changes: 1 addition & 1 deletion spec/spec_helper.rb
Expand Up @@ -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

Expand Down

0 comments on commit 3af22ce

Please sign in to comment.