summaryrefslogtreecommitdiff
path: root/spec/support/integration_test_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/integration_test_helper.rb')
-rw-r--r--spec/support/integration_test_helper.rb46
1 files changed, 39 insertions, 7 deletions
diff --git a/spec/support/integration_test_helper.rb b/spec/support/integration_test_helper.rb
index c4c0d88..bcc5c1f 100644
--- a/spec/support/integration_test_helper.rb
+++ b/spec/support/integration_test_helper.rb
@@ -1,4 +1,42 @@
module IntegrationTestHelper
+ class Report
+ attr_reader :report
+
+ def initialize(raw)
+ @report = JSON.parse(raw, symbolize_names: true)
+ end
+
+ def [](key)
+ report[key]
+ end
+
+ def dependency_names
+ report[:dependencies].map { |x| x[:name] }
+ end
+
+ def licenses_for(name)
+ find(name)[:licenses]
+ end
+
+ def find(name)
+ report[:dependencies].find do |dependency|
+ dependency[:name] == name
+ end
+ end
+
+ def nil?
+ report.nil?
+ end
+
+ def to_hash
+ to_h
+ end
+
+ def to_h
+ report
+ end
+ end
+
class IntegrationTestRunner
attr_reader :project_path
@@ -30,7 +68,7 @@ module IntegrationTestHelper
report_path = "#{project_path}/gl-license-management-report.json"
return {} unless File.exist?(report_path)
- JSON.parse(IO.read(report_path), symbolize_names: true)
+ Report.new(IO.read(report_path))
end
def execute(env = {}, *args)
@@ -47,10 +85,4 @@ module IntegrationTestHelper
def runner(*args)
@runner ||= IntegrationTestRunner.new(*args)
end
-
- def find_in(report, name)
- report[:dependencies].find do |dependency|
- dependency[:name] == name
- end
- end
end