diff options
Diffstat (limited to 'spec/lib/gitlab/ci/config/entry/pages_spec.rb')
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/pages_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/pages_spec.rb b/spec/lib/gitlab/ci/config/entry/pages_spec.rb new file mode 100644 index 00000000000..0ee692a443e --- /dev/null +++ b/spec/lib/gitlab/ci/config/entry/pages_spec.rb @@ -0,0 +1,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 |