summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/ci/yaml_processor/result_spec.rb
blob: 7e3cd7ec2545d587048e3e480c45c77a770a407b (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
# frozen_string_literal: true

require 'spec_helper'

module Gitlab
  module Ci
    class YamlProcessor
      RSpec.describe Result do
        include StubRequests

        let(:user) { create(:user) }
        let(:ci_config) { Gitlab::Ci::Config.new(config_content, user: user) }
        let(:result) { described_class.new(ci_config: ci_config, warnings: ci_config&.warnings) }

        describe '#merged_yaml' do
          subject(:merged_yaml) { result.merged_yaml }

          let(:config_content) do
            YAML.dump(
              include: { remote: 'https://example.com/sample.yml' },
              test: { stage: 'test', script: 'echo' }
            )
          end

          let(:included_yml) do
            YAML.dump(
              another_test: { stage: 'test', script: 'echo 2' }
            )
          end

          before do
            stub_full_request('https://example.com/sample.yml').to_return(body: included_yml)
          end

          it 'returns expanded yaml config' do
            expanded_config = YAML.safe_load(merged_yaml, [Symbol])
            included_config = YAML.safe_load(included_yml, [Symbol])

            expect(expanded_config).to include(*included_config.keys)
          end
        end
      end
    end
  end
end