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

block_spec.rb « interpolation « ci « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4a8709df3dcf87e781cb2261ccc8b0147ecb7c1b (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
# frozen_string_literal: true

require 'fast_spec_helper'

RSpec.describe Gitlab::Ci::Interpolation::Block, feature_category: :pipeline_composition do
  subject { described_class.new(block, data, ctx) }

  let(:data) do
    'inputs.data'
  end

  let(:block) do
    "$[[ #{data} ]]"
  end

  let(:ctx) do
    { inputs: { data: 'abc' }, env: { 'ENV' => 'dev' } }
  end

  it 'knows its content' do
    expect(subject.content).to eq 'inputs.data'
  end

  it 'properly evaluates the access pattern' do
    expect(subject.value).to eq 'abc'
  end

  describe '.match' do
    it 'matches each block in a string' do
      expect { |b| described_class.match('$[[ access1 ]] $[[ access2 ]]', &b) }
        .to yield_successive_args(['$[[ access1 ]]', 'access1'], ['$[[ access2 ]]', 'access2'])
    end

    it 'matches an empty block' do
      expect { |b| described_class.match('$[[]]', &b) }
        .to yield_with_args('$[[]]', '')
    end
  end
end