Welcome to mirror list, hosted at ThFree Co, Russian Federation.

pages_spec.rb « entry « config « ci « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0ee692a443e6ece8174b8ee68c430816a9fef614 (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
39
40
41
42
43
44
45
46
47
48
49
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Ci::Config::Entry::Pages, feature_category: :pages do
  subject(:entry) { described_class.new(config) }

  describe 'validation' do
    context 'when value given is not a hash' do
      let(:config) { 'value' }

      it 'is invalid' do
        expect(entry).not_to be_valid
        expect(entry.errors).to include('pages config should be a hash')
      end
    end

    context 'when value is a hash' do
      context 'when the hash is valid' do
        let(:config) { { path_prefix: 'prefix' } }

        it 'is valid' do
          expect(entry).to be_valid
          expect(entry.value).to eq({
            path_prefix: 'prefix'
          })
        end
      end

      context 'when path_prefix key is not a string' do
        let(:config) { { path_prefix: 1 } }

        it 'is invalid' do
          expect(entry).not_to be_valid
          expect(entry.errors).to include('pages path prefix should be a string')
        end
      end

      context 'when hash contains not allowed keys' do
        let(:config) { { unknown: 'echo' } }

        it 'is invalid' do
          expect(entry).not_to be_valid
          expect(entry.errors).to include('pages config contains unknown keys: unknown')
        end
      end
    end
  end
end