Sha256: 0def1c46247a6c66261cce19f6c1bbd6a06a458d77bcf6eb84fa3f31e82e4761

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

require 'spec_helper'
require 'git_helper'

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, ask: 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)
    allow(subject).to receive(:puts)
  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(:ask)
      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-3.3.2 spec/git_helper/new_branch_spec.rb