Permalink
Browse files

Merge branch 'push-without-remote' of github.com:bryan-ash/kumade int…

…o push-without-remote
  • Loading branch information...
2 parents ccfa677 + 2ac8ca8 commit aa529b634cd7e7f951dd55dd0552ed01c5bc9781 @bryan-ash bryan-ash committed Nov 3, 2011
Showing with 32 additions and 16 deletions.
  1. +1 −0 lib/kumade/git.rb
  2. +31 −16 spec/kumade/git_spec.rb
View
@@ -11,6 +11,7 @@ def self.environments
end
def push(branch, remote = 'origin', force = false)
+ return unless remote_exists?(remote)
command = ["git push"]
command << "-f" if force
command << remote
@@ -43,27 +43,42 @@
describe Kumade::Git, "#push", :with_mock_outputter do
let(:branch) { 'branch' }
let(:remote) { 'my-remote' }
- let(:command_line) { stub("Kumade::CommandLine instance", :run_or_error => true) }
- before do
- Kumade::CommandLine.stubs(:new => command_line)
- end
+ context "when the remote exists" do
+ let(:command_line) { stub("Kumade::CommandLine instance", :run_or_error => true) }
- it "pushes to the correct remote" do
- subject.push(branch, remote)
- Kumade::CommandLine.should have_received(:new).with("git push #{remote} #{branch}")
- command_line.should have_received(:run_or_error).once
- end
+ before do
+ Kumade::CommandLine.stubs(:new => command_line)
+ subject.stubs(:remote_exists? => true)
+ end
+
+ it "pushes to the correct remote" do
+ subject.push(branch, remote)
+ Kumade::CommandLine.should have_received(:new).with("git push #{remote} #{branch}")
+ command_line.should have_received(:run_or_error).once
+ end
- it "can force push" do
- subject.push(branch, remote, true)
- Kumade::CommandLine.should have_received(:new).with("git push -f #{remote} #{branch}")
- command_line.should have_received(:run_or_error).once
+ it "can force push" do
+ subject.push(branch, remote, true)
+ Kumade::CommandLine.should have_received(:new).with("git push -f #{remote} #{branch}")
+ command_line.should have_received(:run_or_error).once
+ end
+
+ it "prints a success message" do
+ subject.push(branch, remote)
+ Kumade.configuration.outputter.should have_received(:success).with("Pushed #{branch} -> #{remote}")
+ end
end
- it "prints a success message" do
- subject.push(branch, remote)
- Kumade.configuration.outputter.should have_received(:success).with("Pushed #{branch} -> #{remote}")
+ context "when the remote does not exist" do
+ before do
+ subject.stubs(:remote_exists? => false)
+ end
+
+ it "returns silently" do
+ subject.push(branch)
+ Kumade::CommandLine.should have_received(:new).never
+ end
end
end

0 comments on commit aa529b6

Please sign in to comment.