Sha256: 5b16f9b6cf59753cd05a23e8ab9073af2a36aff7deb8dd66a1e03bf3125f4801

Contents?: true

Size: 1.75 KB

Versions: 25

Compression:

Stored size: 1.75 KB

Contents

describe KnapsackPro::Config::CI::Buildkite 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 }

    context 'when environment exists' do
      let(:env) { { 'BUILDKITE_PARALLEL_JOB_COUNT' => 4 } }
      it { should eql 4 }
    end

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

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

    context 'when environment exists' do
      let(:env) { { 'BUILDKITE_PARALLEL_JOB' => 3 } }
      it { should eql 3 }
    end

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

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

    context 'when environment exists' do
      let(:env) { { 'BUILDKITE_COMMIT' => '3fa64859337f6e56409d49f865d13fd7' } }
      it { should eql '3fa64859337f6e56409d49f865d13fd7' }
    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
      let(:env) { { 'BUILDKITE_BRANCH' => 'master' } }
      it { should eql 'master' }
    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) { { 'BUILDKITE_BUILD_CHECKOUT_PATH' => '/home/user/knapsack_pro-ruby' } }
      it { should eql '/home/user/knapsack_pro-ruby' }
    end

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

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
knapsack_pro-0.17.0 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.16.0 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.15.2 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.15.1 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.15.0 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.14.0 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.13.0 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.12.0 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.11.0 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.10.0 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.9.0 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.8.0 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.7.2 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.7.1 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.7.0 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.6.1 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.6.0 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.5.0 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.4.0 spec/knapsack_pro/config/ci/buildkite_spec.rb
knapsack_pro-0.3.0 spec/knapsack_pro/config/ci/buildkite_spec.rb