Sha256: 35a603be892cae5162bdfe646bc849bfec10063f36e34636a94b035bd523358a

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require_relative '../../lib/git_helper/new_branch.rb'

describe GitHelper::NewBranch do
  let(:new_branch_name) { 'new-branch-name' }
  let(:local_code) { double(:local_code, new_branch: :commit) }
  let(:cli) { double(:highline_cli, new_branch_name: new_branch_name) }

  subject { GitHelper::NewBranch.new }

  before do
    allow(GitHelper::LocalCode).to receive(:new).and_return(local_code)
    allow(GitHelper::HighlineCli).to receive(:new).and_return(cli)
  end

  it 'should call GitHelper::LocalCode' do
    expect(GitHelper::LocalCode).to receive(:new).and_return(local_code)
    subject.execute
  end

  it 'should call the new_branch method from the local code class' do
    expect(local_code).to receive(:new_branch)
    subject.execute
  end

  context 'when no branch name is passed in' do
    it 'should call the highline cli' do
      expect(GitHelper::HighlineCli).to receive(:new).and_return(cli)
      subject.execute
    end

    it 'should ask the highline cli what the new branch name should be' do
      expect(cli).to receive(:new_branch_name)
      subject.execute
    end
  end

  context 'when there is a branch name passed in' do
    it 'should not create a highline cli' do
      expect(GitHelper::HighlineCli).not_to receive(:new)
      subject.execute(new_branch_name)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git_helper-2.0.0 spec/git_helper/new_branch_spec.rb