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