Sha256: 2773c9ed61ac1f9761112ea4de85e41bbd3352fa5fbb5e6555ef168d3a4c8b7c

Contents?: true

Size: 1.46 KB

Versions: 42

Compression:

Stored size: 1.46 KB

Contents

require "spec_helper"
require "octopolo/scripts/sync_branch"

module Octopolo
  module Scripts
    describe SyncBranch do
      let(:config) { stub(:config, :deploy_branch => "production") }
      let(:git) { stub(:Git) }
      let(:cli) { stub(:CLI) }
      let(:otherbranch) { "otherbranch" }

      subject { SyncBranch.new }

      before do
        SyncBranch.any_instance.stub({
          :config => config,
          :git => git,
          :cli => cli
        })
      end

      context "#parse" do
        it "accepts the given branch name as the branch to merge" do
          expect(SyncBranch.new(otherbranch).branch).to eq(otherbranch)
        end

        it "defaults to the deploy branch" do
          expect(subject.branch).to eq(config.deploy_branch)
        end
      end

      context "#execute" do
        it "merges the remote branch into yours" do
          subject.should_receive(:merge_branch)
          subject.execute
        end
      end

      context "#merge_branch" do
        before do
          subject.branch = otherbranch
        end

        it "merges the remote branch into yours" do
          git.should_receive(:merge).with(subject.branch)
          subject.merge_branch
        end

        it "properly handles a merge failure" do
          git.should_receive(:merge).and_raise(Git::MergeFailed)
          cli.should_receive(:say).with("Merge failed. Please resolve these conflicts.")
          subject.merge_branch
        end
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
octopolo-1.1.0 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-1.0.2 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-1.0.1 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-1.0.0 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-0.4.1 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-0.4.0 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-0.3.6 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-0.3.5 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-0.3.4 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-0.3.3 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-0.3.2 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-0.3.1 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-0.3.0 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-0.2.1 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-0.1.4 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-0.2.0 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-0.1.3 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-0.1.2 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-0.1.1 spec/octopolo/scripts/sync_branch_spec.rb
octopolo-0.1.0 spec/octopolo/scripts/sync_branch_spec.rb