Sha256: 5aa4725eecc8e22e1439ba30cfbbc0f2c10d567d60e4f8eece12614436182426

Contents?: true

Size: 1.54 KB

Versions: 3

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

describe Circleci::Bundle::Update::Pr do
  describe '.github_host' do
    subject { Circleci::Bundle::Update::Pr.send(:github_host) }

    after { ENV['CIRCLE_REPOSITORY_URL'] = nil }

    context "when ENV['CIRCLE_REPOSITORY_URL'] is git@github.com:masutaka/compare_linker.git" do
      before { ENV['CIRCLE_REPOSITORY_URL'] = 'git@github.com:masutaka/compare_linker.git' }

      it { is_expected.to eq 'github.com' }
    end

    context "when ENV['CIRCLE_REPOSITORY_URL'] is https://github.com/masutaka/circleci-bundle-update-pr.git" do
      before { ENV['CIRCLE_REPOSITORY_URL'] = 'https://github.com/masutaka/circleci-bundle-update-pr.git' }

      it { is_expected.to eq 'github.com' }
    end

    context "with ENV['CIRCLE_REPOSITORY_URL'] is nil" do
      before { ENV['CIRCLE_REPOSITORY_URL'] = nil }

      it { is_expected.to eq 'github.com' }
    end
  end

  describe '.target_branch?' do
    subject do
      Circleci::Bundle::Update::Pr.send(
        :target_branch?,
        running_branch: running_branch,
        target_branches: ['target']
      )
    end

    context 'when running_target is included in target branches' do
      let(:running_branch) { 'target' }

      it { is_expected.to be_truthy }
    end

    context "when ENV['CIRCLE_BRANCH'] is not included in target branches" do
      let(:running_branch) { 'not_included' }

      it { is_expected.to be_falsy }
    end

    context "when ENV['CIRCLE_BRANCH'] is nil" do
      let(:running_branch) { nil }

      it { is_expected.to be_falsy }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
circleci-bundle-update-pr-1.17.0 spec/circleci/bundle/update/pr_spec.rb
circleci-bundle-update-pr-1.16.1 spec/circleci/bundle/update/pr_spec.rb
circleci-bundle-update-pr-1.16.0 spec/circleci/bundle/update/pr_spec.rb