diff options
Diffstat (limited to 'spec/lib/gitlab/ci/config/entry/kubernetes_spec.rb')
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/kubernetes_spec.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/kubernetes_spec.rb b/spec/lib/gitlab/ci/config/entry/kubernetes_spec.rb new file mode 100644 index 00000000000..468e83ec506 --- /dev/null +++ b/spec/lib/gitlab/ci/config/entry/kubernetes_spec.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::Ci::Config::Entry::Kubernetes do + subject { described_class.new(config) } + + describe 'attributes' do + it { is_expected.to respond_to(:namespace) } + it { is_expected.to respond_to(:has_namespace?) } + end + + describe 'validations' do + describe 'config' do + context 'is a hash containing known keys' do + let(:config) { Hash(namespace: 'namespace') } + + it { is_expected.to be_valid } + end + + context 'is a hash containing an unknown key' do + let(:config) { Hash(unknown: 'attribute') } + + it { is_expected.not_to be_valid } + end + + context 'is a string' do + let(:config) { 'config' } + + it { is_expected.not_to be_valid } + end + end + + describe 'namespace' do + let(:config) { Hash(namespace: namespace) } + + context 'is a string' do + let(:namespace) { 'namespace' } + + it { is_expected.to be_valid } + end + + context 'is a hash' do + let(:namespace) { Hash(key: 'namespace') } + + it { is_expected.not_to be_valid } + end + + context 'is not present' do + let(:namespace) { '' } + + it { is_expected.not_to be_valid } + end + end + end +end |