summaryrefslogtreecommitdiff
path: root/spec/support/scanner_context.rb
blob: 6a17835572f0de18f2a268f158271dbe5ae45fb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
RSpec.shared_context 'a 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) { self.class.description }
  let(:project) { Project.new }
  let(:report_type) { raise 'report_type not specified'  }
  let(:env) { { } }

  around :example do |example|
    project.mount(dir: fixture_file(project_fixture))
    docker.run(image: docker_image, project_path: project.path, env: env)
    example.run
    project.cleanup
  end
end

RSpec.configure do |config|
  config.include_context 'a scanner'
end