spec/gitx/cli/update_command_spec.rb in gitx-2.21.3 vs spec/gitx/cli/update_command_spec.rb in gitx-2.21.4.ci.145.1

- old
+ new

@@ -7,13 +7,14 @@ let(:config) do { pretend: true } end - let(:cli) { Gitx::Cli::UpdateCommand.new(args, options, config) } + let(:cli) { described_class.new(args, options, config) } let(:branch) { double('fake branch', name: 'feature-branch') } let(:repo) { cli.send(:repo) } + let(:executor) { cli.send(:executor) } let(:remote_branch_names) { ['origin/feature-branch'] } before do allow(cli).to receive(:current_branch).and_return(branch) branches = double('fake branches') @@ -24,13 +25,13 @@ describe '#update' do context 'when no merge conflicts occur' do before do allow(cli).to receive(:say) - expect(cli).to receive(:run_cmd).with('git pull origin feature-branch').ordered - expect(cli).to receive(:run_cmd).with('git pull origin master').ordered - expect(cli).to receive(:run_cmd).with('git push origin HEAD').ordered + expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'feature-branch').ordered + expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'master').ordered + expect(executor).to receive(:execute).with('git', 'share').ordered cli.update end it 'runs expected commands' do should meet_expectations @@ -38,37 +39,37 @@ end context 'when merge conflicts occur when pulling remote feature-branch' do before do allow(cli).to receive(:say) - expect(cli).to receive(:run_cmd).with('git pull origin feature-branch').and_raise('merge error').ordered + expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'feature-branch').and_raise('merge error').ordered - expect { cli.update }.to raise_error(Gitx::Cli::BaseCommand::MergeError, 'Merge Conflict Occurred. Please fix merge conflict and rerun the update command') + expect { cli.update }.to raise_error(Gitx::Cli::BaseCommand::MergeError, 'Merge conflict occurred. Please fix merge conflict and rerun the command') end it 'raises error' do should meet_expectations end end context 'when merge conflicts occur when pulling remote master branch' do before do allow(cli).to receive(:say) - expect(cli).to receive(:run_cmd).with('git pull origin feature-branch').ordered - expect(cli).to receive(:run_cmd).with('git pull origin master').and_raise('merge error occurred').ordered + expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'feature-branch').ordered + expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'master').and_raise('merge error occurred').ordered - expect { cli.update }.to raise_error(Gitx::Cli::BaseCommand::MergeError, 'Merge Conflict Occurred. Please fix merge conflict and rerun the update command') + expect { cli.update }.to raise_error(Gitx::Cli::BaseCommand::MergeError, 'Merge conflict occurred. Please fix merge conflict and rerun the command') end it 'raises error' do should meet_expectations end end context 'when feature-branch does not exist remotely' do let(:remote_branch_names) { [] } before do allow(cli).to receive(:say) - expect(cli).not_to receive(:run_cmd).with('git pull origin feature-branch') - expect(cli).to receive(:run_cmd).with('git pull origin master').ordered + expect(executor).not_to receive(:execute).with('git', 'pull', 'origin', 'feature-branch') + expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'master').ordered cli.update end it 'skips pulling from feature branch' do should meet_expectations