summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/ci/config/entry/services_spec.rb
blob: b32e52f8f260170bfd24038761792927d8253457 (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
require 'spec_helper'

describe Gitlab::Ci::Config::Entry::Services do
  let(:entry) { described_class.new(config) }

  before { entry.compose! }

  context 'when configuration is valid' do
    let(:config) { ['postgresql:9.5', { name: 'postgresql:9.1', alias: 'postgres_old' }] }

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

    describe '#value' do
      it 'returns valid array' do
        expect(entry.value).to eq([{ name: 'postgresql:9.5' }, { name: 'postgresql:9.1', alias: 'postgres_old' }])
      end
    end
  end

  context 'when configuration is invalid' do
    let(:config) { 'postgresql:9.5' }

    describe '#valid?' do
      it 'is invalid' do
        expect(entry).not_to be_valid
      end
    end
  end
end