summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-01-09 09:20:04 -0700
committermo khan <mo.khan@gmail.com>2020-01-09 09:20:04 -0700
commitfe4d46abda860db5cdb3f24f3ab083c90ea139ed (patch)
tree60d0aa4e9a70840cb9aea613371adb63d7ce3e8d /spec/support
parenteb54b7a153c2b7b3b7e82ca2c6449890b3d88bf4 (diff)
parentf16af48f9b7cf99e8d1cdb1e44dad9aad3a090b6 (diff)
Merge with master
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/integration_test_helper.rb37
1 files changed, 37 insertions, 0 deletions
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