summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-02-14 10:33:23 -0700
committermo khan <mo.khan@gmail.com>2020-02-14 10:33:23 -0700
commit94b7c0a650af89f366e5317ff6a28355528ec30b (patch)
tree0da64d5d1065587f5a617fba5b1403398a5e87f2
parent094cf086bc47e52a9cae19befc05efb82b33da08 (diff)
Apply reviewer feedback
-rw-r--r--spec/integration/java/gradle_spec.rb39
-rw-r--r--spec/support/integration_test_helper.rb6
-rw-r--r--spec/support/matchers.rb9
3 files changed, 29 insertions, 25 deletions
diff --git a/spec/integration/java/gradle_spec.rb b/spec/integration/java/gradle_spec.rb
index 6516cf6..fc52c72 100644
--- a/spec/integration/java/gradle_spec.rb
+++ b/spec/integration/java/gradle_spec.rb
@@ -23,29 +23,28 @@ plugins {
end
end
- def find_in(report, name)
- report[:dependencies].find do |dependency|
- dependency[:name] == name
- end
- end
+ context 'when scanning a gradle project that does not include the `com.github.hierynomus.license` plugin' do
+ let(:project_url) { 'https://gitlab.com/one-touch-pipeline/otp.git' }
+ let(:result) { runner.scan }
- it 'scans https://gitlab.com/one-touch-pipeline/otp.git' do
- runner.clone('https://gitlab.com/one-touch-pipeline/otp.git')
- report = runner.scan
+ before do
+ runner.clone(project_url)
+ end
- expect(report).not_to be_empty
- expect(report).to match_schema(version: '2.0')
- expect(report[:licenses].count).not_to be_zero
- expect(report[:dependencies].count).not_to be_zero
+ it 'is able to detect licenses' do
+ expect(result).not_to be_empty
+ expect(result).to match_schema(version: '2.0')
+ expect(result[:licenses]).not_to be_empty
- [
- { name: 'ant', licenses: ['Apache-2.0'] },
- { name: 'activation', licenses: ['CDDL-1.0'] },
- { name: 'xml-apis', licenses: ['Apache-2.0', 'SAX-PD', 'W3C-20150513'] },
- { name: 'sitemesh', licenses: ['Apache-1.1'] },
- { name: 'hibernate-jpa-2.1-api', licenses: ['BSD-3-Clause', 'EPL-1.0'] },
- ].each do |item|
- expect(find_in(report, item[:name])[:licenses]).to match_array(item[:licenses])
+ [
+ { name: 'ant', licenses: ['Apache-2.0'] },
+ { name: 'activation', licenses: ['CDDL-1.0'] },
+ { name: 'xml-apis', licenses: ['Apache-2.0', 'SAX-PD', 'W3C-20150513'] },
+ { name: 'sitemesh', licenses: ['Apache-1.1'] },
+ { name: 'hibernate-jpa-2.1-api', licenses: ['BSD-3-Clause', 'EPL-1.0'] },
+ ].each do |dependency|
+ expect(find_in(result, dependency[:name])[:licenses]).to match_array(dependency[:licenses])
+ end
end
end
end
diff --git a/spec/support/integration_test_helper.rb b/spec/support/integration_test_helper.rb
index e05ef43..09843c3 100644
--- a/spec/support/integration_test_helper.rb
+++ b/spec/support/integration_test_helper.rb
@@ -40,4 +40,10 @@ 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
diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb
index 1d1c263..12bbdf7 100644
--- a/spec/support/matchers.rb
+++ b/spec/support/matchers.rb
@@ -1,10 +1,9 @@
RSpec::Matchers.define :match_schema do |version: '2.0'|
+ def schema_for(version)
+ License::Management.root.join("spec/fixtures/schema/v#{version}.json").to_s
+ end
match do |actual|
- schema = License::Management.root
- .join("spec/fixtures/schema/v#{version}.json")
- .to_s
- @errors = JSON::Validator.fully_validate(schema, actual)
- @errors.empty?
+ !actual.nil? && JSON::Validator.fully_validate(schema_for(version), actual).empty?
end
failure_message do |response|