From d89872f850332736eb174f2b0ab28692fda6bf46 Mon Sep 17 00:00:00 2001 From: mo khan Date: Thu, 9 Jan 2020 11:26:40 +0000 Subject: Upgrade python from 3.5 to 3.8 --- spec/support/integration_test_helper.rb | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 spec/support/integration_test_helper.rb (limited to 'spec/support') diff --git a/spec/support/integration_test_helper.rb b/spec/support/integration_test_helper.rb new file mode 100644 index 0000000..df75176 --- /dev/null +++ b/spec/support/integration_test_helper.rb @@ -0,0 +1,37 @@ +module IntegrationTestHelper + class IntegrationTestRunner + attr_reader :project_path + + def initialize(project_path = Dir.mktmpdir('lm')) + @project_path = project_path + end + + def add_file(name, content = nil) + full_path = "#{project_path}/#{name}" + IO.write(full_path, block_given? ? yield : content) + end + + def scan(env: {}) + return {} unless execute(env, './bin/test-local', project_path) + + report_path = "#{project_path}/gl-license-management-report.json" + return {} unless File.exist?(report_path) + + JSON.parse(IO.read(report_path), symbolize_names: true) + end + + def execute(env = {}, *args) + Bundler.with_clean_env do + system(env, *args) + end + end + + def cleanup + FileUtils.rm_rf(project_path) if Dir.exist?(project_path) + end + end + + def runner(*args) + @runner ||= IntegrationTestRunner.new(*args) + end +end -- cgit v1.2.3