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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/ci/components/header_spec.rb')
-rw-r--r--spec/lib/gitlab/ci/components/header_spec.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/components/header_spec.rb b/spec/lib/gitlab/ci/components/header_spec.rb
new file mode 100644
index 00000000000..b1af4ca9238
--- /dev/null
+++ b/spec/lib/gitlab/ci/components/header_spec.rb
@@ -0,0 +1,50 @@
+# frozen_string_literal: true
+
+require 'fast_spec_helper'
+
+RSpec.describe Gitlab::Ci::Components::Header, feature_category: :pipeline_composition do
+ subject { described_class.new(spec) }
+
+ context 'when spec is valid' do
+ let(:spec) do
+ {
+ spec: {
+ inputs: {
+ website: nil,
+ run: {
+ options: %w[opt1 opt2]
+ }
+ }
+ }
+ }
+ end
+
+ it 'fabricates a spec from valid data' do
+ expect(subject).not_to be_empty
+ end
+
+ describe '#inputs' do
+ it 'fabricates input data' do
+ input = subject.inputs({ website: 'https//gitlab.com', run: 'opt1' })
+
+ expect(input.count).to eq 2
+ end
+ end
+
+ describe '#context' do
+ it 'fabricates interpolation context' do
+ ctx = subject.context({ website: 'https//gitlab.com', run: 'opt1' })
+
+ expect(ctx).to be_valid
+ end
+ end
+ end
+
+ context 'when spec is empty' do
+ let(:spec) { { spec: {} } }
+
+ it 'returns an empty header' do
+ expect(subject).to be_empty
+ end
+ end
+end