Sha256: d5f8aabc6a2ef4cba432ff004d0a6eab1990d069c474b1252267656f9e992557

Contents?: true

Size: 1.89 KB

Versions: 17

Compression:

Stored size: 1.89 KB

Contents

describe KnapsackPro::Config::CI::GithubActions do
  let(:env) { {} }

  before do
    stub_const('ENV', env)
  end

  it { should be_kind_of KnapsackPro::Config::CI::Base }

  describe '#node_total' do
    subject { described_class.new.node_total }

    it { should be nil }
  end

  describe '#node_index' do
    subject { described_class.new.node_index }

    it { should be nil }
  end

  describe '#node_build_id' do
    subject { described_class.new.node_build_id }

    it { should be nil }
  end

  describe '#commit_hash' do
    subject { described_class.new.commit_hash }

    context 'when environment exists' do
      let(:env) { { 'GITHUB_SHA' => '2e13512fc230d6f9ebf4923352718e4d' } }
      it { should eql '2e13512fc230d6f9ebf4923352718e4d' }
    end

    context "when environment doesn't exist" do
      it { should be nil }
    end
  end

  describe '#branch' do
    subject { described_class.new.branch }

    context 'when environment exists' do
      context 'when GITHUB_REF has value' do
        let(:env) do
          {
            'GITHUB_REF' => 'master',
            'GITHUB_SHA' => '2e13512fc230d6f9ebf4923352718e4d',
          }
        end

        it { should eql 'master' }
      end

      context 'when GITHUB_REF is not set' do
        let(:env) do
          {
            'GITHUB_SHA' => '2e13512fc230d6f9ebf4923352718e4d',
          }
        end

        it { should eql '2e13512fc230d6f9ebf4923352718e4d' }
      end
    end

    context "when environment doesn't exist" do
      it { should be nil }
    end
  end

  describe '#project_dir' do
    subject { described_class.new.project_dir }

    context 'when environment exists' do
      let(:env) { { 'GITHUB_WORKSPACE' => '/home/runner/work/my-repo-name/my-repo-name' } }
      it { should eql '/home/runner/work/my-repo-name/my-repo-name' }
    end

    context "when environment doesn't exist" do
      it { should be nil }
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
knapsack_pro-1.22.3 spec/knapsack_pro/config/ci/github_actions_spec.rb
knapsack_pro-1.22.2 spec/knapsack_pro/config/ci/github_actions_spec.rb
knapsack_pro-1.22.1 spec/knapsack_pro/config/ci/github_actions_spec.rb
knapsack_pro-1.22.0 spec/knapsack_pro/config/ci/github_actions_spec.rb
knapsack_pro-1.21.0 spec/knapsack_pro/config/ci/github_actions_spec.rb
knapsack_pro-1.20.2 spec/knapsack_pro/config/ci/github_actions_spec.rb
knapsack_pro-1.20.1 spec/knapsack_pro/config/ci/github_actions_spec.rb
knapsack_pro-1.20.0 spec/knapsack_pro/config/ci/github_actions_spec.rb
knapsack_pro-1.19.0 spec/knapsack_pro/config/ci/github_actions_spec.rb
knapsack_pro-1.18.2 spec/knapsack_pro/config/ci/github_actions_spec.rb
knapsack_pro-1.18.1 spec/knapsack_pro/config/ci/github_actions_spec.rb
knapsack_pro-1.18.0 spec/knapsack_pro/config/ci/github_actions_spec.rb
knapsack_pro-1.17.0 spec/knapsack_pro/config/ci/github_actions_spec.rb
knapsack_pro-1.16.1 spec/knapsack_pro/config/ci/github_actions_spec.rb
knapsack_pro-1.16.0 spec/knapsack_pro/config/ci/github_actions_spec.rb
knapsack_pro-1.15.0 spec/knapsack_pro/config/ci/github_actions_spec.rb
knapsack_pro-1.14.0 spec/knapsack_pro/config/ci/github_actions_spec.rb