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

coverage_spec.rb « entry « config « ci « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c4353e822ae7e7386394502a1f8501aab3c52b50 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Ci::Config::Entry::Coverage do
  let(:entry) { described_class.new(config) }

  describe 'validations' do
    context "when entry config value doesn't have the surrounding '/'" do
      let(:config) { 'Code coverage: \d+\.\d+' }

      describe '#errors' do
        subject { entry.errors }

        it { is_expected.to include(/coverage config must be a regular expression/) }
      end

      describe '#valid?' do
        subject { entry }

        it { is_expected.not_to be_valid }
      end
    end

    context "when entry config value has the surrounding '/'" do
      let(:config) { '/Code coverage: \d+\.\d+/' }

      describe '#value' do
        subject { entry.value }

        it { is_expected.to eq(config[1...-1]) }
      end

      describe '#errors' do
        subject { entry.errors }

        it { is_expected.to be_empty }
      end

      describe '#valid?' do
        subject { entry }

        it { is_expected.to be_valid }
      end
    end

    context 'when entry value is not valid' do
      let(:config) { '(malformed regexp' }

      describe '#errors' do
        subject { entry.errors }

        it { is_expected.to include(/coverage config must be a regular expression/) }
      end

      describe '#valid?' do
        subject { entry }

        it { is_expected.not_to be_valid }
      end
    end
  end
end