blob: 421ff95a7ed0adf362fb5593a421aeadae925848 (
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
|
# frozen_string_literal: true
RSpec.shared_context 'with scanner' do
subject { project.report_for(type: report_type) }
let(:docker) { Docker.new(pwd: Pathname.pwd.join("src/#{scanner}")) }
let(:docker_image) { "#{scanner}:latest" }
let(:scanner) { raise "`scanner` not specified. Choose: #{Pathname.pwd.glob('src/*').map(&:basename).join(', ')}" }
let(:project) { Project.new }
let(:project_fixture) { nil }
let(:env) { {} }
let(:report_type) { report_types.fetch(scanner) }
let(:report_types) do
{
'gemnasium-maven' => :dependency_scanning,
'klar' => :"container-scanning",
'spotbugs' => :sast
}
end
around do |example|
if project_fixture
project.mount(dir: fixture_file(project_fixture))
else
project.clone(git_url, branch: git_branch.to_s)
end
docker.run(image: docker_image, project_path: project.path, env: env)
example.run
project.cleanup
end
end
RSpec.configure do |config|
config.include_context 'with scanner'
end
|