summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/ci/config/node/stage_spec.rb
blob: fb9ec70762abe49e6cb78e10de2190f1f5a2dc91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'spec_helper'

describe Gitlab::Ci::Config::Node::Stage do
  let(:stage) { described_class.new(config) }

  describe 'validations' do
    context 'when stage config value is correct' do
      let(:config) { 'build' }

      describe '#value' do
        it 'returns a stage key' do
          expect(stage.value).to eq config
        end
      end

      describe '#valid?' do
        it 'is valid' do
          expect(stage).to be_valid
        end
      end
    end

    context 'when value has a wrong type' do
      let(:config) { { test: true } }

      it 'reports errors about wrong type' do
        expect(stage.errors)
          .to include 'stage config should be a string'
      end
    end
  end

  describe '.default' do
    it 'returns default stage' do
      expect(described_class.default).to eq 'test'
    end
  end
end