2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe TemplateFinder do
|
|
|
|
using RSpec::Parameterized::TableSyntax
|
|
|
|
|
|
|
|
describe '#build' do
|
2018-12-05 23:21:45 +05:30
|
|
|
let(:project) { build_stubbed(:project) }
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
where(:type, :expected_class) do
|
|
|
|
:dockerfiles | described_class
|
|
|
|
:gitignores | described_class
|
|
|
|
:gitlab_ci_ymls | described_class
|
|
|
|
:licenses | ::LicenseTemplateFinder
|
|
|
|
end
|
|
|
|
|
|
|
|
with_them do
|
2018-12-05 23:21:45 +05:30
|
|
|
subject(:finder) { described_class.build(type, project) }
|
2018-11-20 20:47:30 +05:30
|
|
|
|
|
|
|
it { is_expected.to be_a(expected_class) }
|
2018-12-05 23:21:45 +05:30
|
|
|
it { expect(finder.project).to eq(project) }
|
2018-11-20 20:47:30 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
where(:type, :vendored_name) do
|
|
|
|
:dockerfiles | 'Binary'
|
|
|
|
:gitignores | 'Actionscript'
|
|
|
|
:gitlab_ci_ymls | 'Android'
|
|
|
|
end
|
|
|
|
|
|
|
|
with_them do
|
|
|
|
it 'returns all vendored templates when no name is specified' do
|
2018-12-05 23:21:45 +05:30
|
|
|
result = described_class.new(type, nil).execute
|
2018-11-20 20:47:30 +05:30
|
|
|
|
|
|
|
expect(result).to include(have_attributes(name: vendored_name))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns only the specified vendored template when a name is specified' do
|
2018-12-05 23:21:45 +05:30
|
|
|
result = described_class.new(type, nil, name: vendored_name).execute
|
2018-11-20 20:47:30 +05:30
|
|
|
|
|
|
|
expect(result).to have_attributes(name: vendored_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns nil when an unknown name is specified' do
|
2018-12-05 23:21:45 +05:30
|
|
|
result = described_class.new(type, nil, name: 'unknown').execute
|
2018-11-20 20:47:30 +05:30
|
|
|
|
|
|
|
expect(result).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|