script_spec.rb 1.01 KB
Newer Older
1 2
require 'spec_helper'

3
describe Gitlab::Ci::Config::Node::Script do
4
  let(:entry) { described_class.new(value) }
5

6 7
  describe '#validate!' do
    before { entry.validate! }
8

9 10 11 12 13 14 15
    context 'when entry value is correct' do
      let(:value) { ['ls', 'pwd'] }

      describe '#value' do
        it 'returns concatenated command' do
          expect(entry.value).to eq "ls\npwd"
        end
16
      end
17

18 19 20 21
      describe '#errors' do
        it 'does not append errors' do
          expect(entry.errors).to be_empty
        end
22
      end
23

24 25 26 27
      describe '#valid?' do
        it 'is valid' do
          expect(entry).to be_valid
        end
28 29
      end
    end
30

31 32
    context 'when entry value is not correct' do
      let(:value) { 'ls' }
33

34 35 36
      describe '#errors' do
        it 'saves errors' do
          expect(entry.errors)
37
            .to include 'script: should be an array of strings'
38
        end
39
      end
40

41 42 43 44
      describe '#valid?' do
        it 'is not valid' do
          expect(entry).not_to be_valid
        end
45 46
      end
    end
47
  end
48
end