summaryrefslogtreecommitdiff
path: root/spec/integration/java/gradle_spec.rb
blob: 6516cf62beb2449f044e8e20e23336d6e8d0b6ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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

  def find_in(report, name)
    report[:dependencies].find do |dependency|
      dependency[:name] == name
    end
  end

  it 'scans https://gitlab.com/one-touch-pipeline/otp.git' do
    runner.clone('https://gitlab.com/one-touch-pipeline/otp.git')
    report = runner.scan

    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

    [
      { 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])
    end
  end
end