debian-mirror-gitlab/spec/lib/gitlab/ci/parsers_spec.rb

66 lines
1.6 KiB
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
2018-11-18 11:00:15 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::Ci::Parsers do
2018-11-18 11:00:15 +05:30
describe '.fabricate!' do
subject { described_class.fabricate!(file_type) }
2020-04-08 14:13:33 +05:30
context 'when file_type is junit' do
2018-11-18 11:00:15 +05:30
let(:file_type) { 'junit' }
it 'fabricates the class' do
2019-02-15 15:39:39 +05:30
is_expected.to be_a(described_class::Test::Junit)
2018-11-18 11:00:15 +05:30
end
end
2020-04-08 14:13:33 +05:30
context 'when file_type is cobertura' do
let(:file_type) { 'cobertura' }
it 'fabricates the class' do
is_expected.to be_a(described_class::Coverage::Cobertura)
end
end
2020-05-24 23:13:21 +05:30
context 'when file_type is accessibility' do
let(:file_type) { 'accessibility' }
it 'fabricates the class' do
is_expected.to be_a(described_class::Accessibility::Pa11y)
end
end
2021-02-22 17:27:13 +05:30
context 'when file_type is codequality' do
let(:file_type) { 'codequality' }
it 'fabricates the class' do
is_expected.to be_a(described_class::Codequality::CodeClimate)
end
end
2020-05-24 23:13:21 +05:30
context 'when file_type is terraform' do
let(:file_type) { 'terraform' }
it 'fabricates the class' do
is_expected.to be_a(described_class::Terraform::Tfplan)
end
end
2018-11-18 11:00:15 +05:30
context 'when file_type does not exist' do
let(:file_type) { 'undefined' }
it 'raises an error' do
2019-02-15 15:39:39 +05:30
expect { subject }.to raise_error(Gitlab::Ci::Parsers::ParserNotFoundError)
2018-11-18 11:00:15 +05:30
end
end
end
2021-03-11 19:13:27 +05:30
describe '.instrument!' do
it 'prepends the Instrumentation module into each parser' do
expect(described_class.parsers.values).to all( receive(:prepend).with(Gitlab::Ci::Parsers::Instrumentation) )
described_class.instrument!
end
end
2018-11-18 11:00:15 +05:30
end