2018-11-05 08:45:36 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-08-03 07:13:27 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-11-05 08:45:36 -05:00
|
|
|
describe Gitlab::Ci::Parsers do
|
2018-08-03 07:13:27 -04:00
|
|
|
describe '.fabricate!' do
|
|
|
|
subject { described_class.fabricate!(file_type) }
|
|
|
|
|
2020-03-17 14:09:44 -04:00
|
|
|
context 'when file_type is junit' do
|
2018-08-03 07:13:27 -04:00
|
|
|
let(:file_type) { 'junit' }
|
|
|
|
|
|
|
|
it 'fabricates the class' do
|
2018-11-05 08:45:36 -05:00
|
|
|
is_expected.to be_a(described_class::Test::Junit)
|
2018-08-03 07:13:27 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-17 14:09:44 -04:00
|
|
|
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-05 14:09:43 -04:00
|
|
|
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
|
|
|
|
|
2020-04-21 11:21:10 -04:00
|
|
|
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-08-03 07:13:27 -04:00
|
|
|
context 'when file_type does not exist' do
|
|
|
|
let(:file_type) { 'undefined' }
|
|
|
|
|
|
|
|
it 'raises an error' do
|
2018-11-05 08:45:36 -05:00
|
|
|
expect { subject }.to raise_error(Gitlab::Ci::Parsers::ParserNotFoundError)
|
2018-08-03 07:13:27 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|