From b5b1cae94853f3b6e9d2c11d8c970e7cbfaeb024 Mon Sep 17 00:00:00 2001 From: Karl Matthias Date: Mon, 13 Jan 2014 21:06:45 -0800 Subject: [PATCH] Fix a bunch of test failures due to new git fetch code. --- spec/capistrano_deploy_tags_spec.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/spec/capistrano_deploy_tags_spec.rb b/spec/capistrano_deploy_tags_spec.rb index 2a4b3fd..85dc1ee 100644 --- a/spec/capistrano_deploy_tags_spec.rb +++ b/spec/capistrano_deploy_tags_spec.rb @@ -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')