require 'spec_helper' RSpec.describe "gradle" do context "when running a default gradle build" do it 'scans a gradle project' do content = <<~GRADLE /* * This file was generated by the Gradle 'init' task. * * This is a general purpose Gradle build. * Learn how to create Gradle builds at https://guides.gradle.org/creating-new-gradle-builds */ plugins { id "com.github.hierynomus.license" version "0.15.0" } GRADLE runner.add_file('build.gradle', content) report = runner.scan expect(report).to match_schema(version: '2.0') expect(report[:licenses]).to be_empty expect(report[:dependencies]).to be_empty 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 } before do runner.clone(project_url) end 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 |dependency| expect(find_in(result, dependency[:name])[:licenses]).to match_array(dependency[:licenses]) end end end end