Fix a bunch of test failures due to new git fetch code.

This commit is contained in:
Karl Matthias
2014-01-13 21:06:45 -08:00
parent 72224b2d96
commit b5b1cae948
+9 -3
View File
@@ -24,19 +24,22 @@ describe Capistrano::DeployTags do
end
context "prepare_tree" do
before :each do
before do
configuration.set(:branch, 'master')
configuration.set(:stage, 'test')
end
it "raises an error when not in a git tree" do
FileUtils.chdir '/tmp'
configuration.cdt.stub(exec_success?: true)
expect { configuration.find_and_execute_task('git:prepare_tree') }.to raise_error('git checkout master failed!')
end
it "raises when unable to fetch" do
configuration.cdt.should_receive(:exec_success?).and_return(false)
expect { configuration.find_and_execute_task('git:prepare_tree') }.to raise_error(/'git fetch origin' failed/)
with_clean_repo do
configuration.cdt.should_receive(:exec_success?).and_return(false)
expect { configuration.find_and_execute_task('git:prepare_tree') }.to raise_error(/'git fetch ' failed/)
end
end
context "with a clean git tree" do
@@ -55,6 +58,7 @@ describe Capistrano::DeployTags do
it "does not raise an error when run from a clean tree" do
with_clean_repo do
configuration.cdt.stub(exec_success?: true)
expect { configuration.find_and_execute_task('git:prepare_tree') }.to_not raise_error
end
end
@@ -71,6 +75,7 @@ describe Capistrano::DeployTags do
with_clean_repo do
system('git remote add nowhere git@example.com:nowhere')
configuration.set(:git_remote, 'nowhere')
configuration.cdt.stub(pending_git_changes?: false)
configuration.cdt.should_receive(:safe_run).with('git', 'checkout', 'master')
configuration.cdt.should_receive(:safe_run).with('git', 'pull', 'nowhere', 'master')
configuration.find_and_execute_task('git:prepare_tree')
@@ -79,6 +84,7 @@ describe Capistrano::DeployTags do
it "uses the first remote when one is not specified" do
with_clean_repo do
configuration.cdt.stub(pending_git_changes?: false)
system('git remote add somewhere git@example.com:somewhere')
configuration.cdt.should_receive(:safe_run).with('git', 'checkout', 'master')
configuration.cdt.should_receive(:safe_run).with('git', 'pull', 'somewhere', 'master')