license_finder 0.9.5.1-java → 1.0.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +9 -0
- data/CHANGELOG.rdoc +9 -0
- data/MIT.LICENSE +20 -0
- data/db/migrate/201401302113_re_reassociate_license.rb +23 -0
- data/features/gradle_dependencies.feature +9 -0
- data/features/maven_dependencies.feature +9 -0
- data/features/step_definitions/gradle_steps.rb +8 -0
- data/features/step_definitions/maven_steps.rb +8 -0
- data/features/step_definitions/node_steps.rb +1 -1
- data/features/step_definitions/set_license_steps.rb +0 -1
- data/features/step_definitions/shared_steps.rb +26 -13
- data/lib/license_finder.rb +6 -1
- data/lib/license_finder/cli.rb +13 -9
- data/lib/license_finder/configuration.rb +113 -72
- data/lib/license_finder/dependency_manager.rb +12 -7
- data/lib/license_finder/license.rb +39 -65
- data/lib/license_finder/license/any_matcher.rb +13 -0
- data/lib/license_finder/license/definitions.rb +106 -0
- data/lib/license_finder/license/header_matcher.rb +10 -0
- data/lib/license_finder/license/matcher.rb +17 -0
- data/lib/license_finder/license/template.rb +16 -0
- data/lib/license_finder/license/text.rb +19 -0
- data/lib/license_finder/license_url.rb +1 -4
- data/lib/license_finder/package.rb +18 -2
- data/lib/license_finder/package_managers/bower_package.rb +3 -17
- data/lib/license_finder/package_managers/bundler_package.rb +2 -2
- data/lib/license_finder/package_managers/gradle.rb +29 -0
- data/lib/license_finder/package_managers/gradle_package.rb +41 -0
- data/lib/license_finder/package_managers/maven.rb +31 -0
- data/lib/license_finder/package_managers/maven_package.rb +46 -0
- data/lib/license_finder/package_managers/npm_package.rb +2 -16
- data/lib/license_finder/package_managers/pip_package.rb +7 -7
- data/lib/license_finder/package_saver.rb +1 -1
- data/lib/license_finder/possible_license_file.rb +1 -5
- data/lib/license_finder/possible_license_files.rb +4 -2
- data/lib/license_finder/reports/dependency_report.rb +5 -1
- data/lib/license_finder/reports/detailed_text_report.rb +0 -1
- data/lib/license_finder/reports/formatted_report.rb +21 -0
- data/lib/license_finder/reports/html_report.rb +1 -21
- data/lib/license_finder/reports/markdown_report.rb +1 -21
- data/lib/license_finder/reports/reporter.rb +8 -7
- data/lib/license_finder/reports/text_report.rb +0 -2
- data/lib/license_finder/tables.rb +1 -1
- data/lib/license_finder/tables/dependency.rb +12 -12
- data/lib/license_finder/yml_to_sql.rb +4 -4
- data/license_finder.gemspec +3 -2
- data/readme.md +10 -1
- data/release/publish.sh +10 -7
- data/spec/fixtures/build.gradle +24 -0
- data/spec/fixtures/pom.xml +19 -0
- data/spec/lib/license_finder/cli_spec.rb +13 -3
- data/spec/lib/license_finder/configuration_spec.rb +121 -74
- data/spec/lib/license_finder/dependency_manager_spec.rb +34 -16
- data/spec/lib/license_finder/license/{new_bsd_spec.rb → definitions_spec.rb} +93 -7
- data/spec/lib/license_finder/license_spec.rb +72 -26
- data/spec/lib/license_finder/license_url_spec.rb +10 -14
- data/spec/lib/license_finder/package_managers/bower_package_spec.rb +17 -5
- data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +2 -2
- data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +66 -0
- data/spec/lib/license_finder/package_managers/gradle_spec.rb +89 -0
- data/spec/lib/license_finder/package_managers/maven_package_spec.rb +72 -0
- data/spec/lib/license_finder/package_managers/maven_spec.rb +115 -0
- data/spec/lib/license_finder/package_managers/npm_package_spec.rb +17 -3
- data/spec/lib/license_finder/package_managers/pip_package_spec.rb +27 -5
- data/spec/lib/license_finder/possible_license_file_spec.rb +2 -2
- data/spec/lib/license_finder/{detailed_text_report_spec.rb → reports/detailed_text_report_spec.rb} +0 -0
- data/spec/lib/license_finder/{html_report_spec.rb → reports/html_report_spec.rb} +0 -0
- data/spec/lib/license_finder/{markdown_report_spec.rb → reports/markdown_report_spec.rb} +0 -0
- data/spec/lib/license_finder/reports/reporter_spec.rb +33 -0
- data/spec/lib/license_finder/{text_report_spec.rb → reports/text_report_spec.rb} +0 -0
- data/spec/lib/license_finder/tables/dependency_spec.rb +1 -2
- data/spec/lib/license_finder/tables/license_alias_spec.rb +1 -2
- data/spec/lib/license_finder/yml_to_sql_spec.rb +10 -11
- data/spec/lib/license_finder_spec.rb +5 -71
- metadata +64 -53
- data/features/rails_rake.feature +0 -9
- data/features/step_definitions/rails_rake_steps.rb +0 -12
- data/lib/license_finder/license/apache2.rb +0 -8
- data/lib/license_finder/license/bsd.rb +0 -4
- data/lib/license_finder/license/gplv2.rb +0 -4
- data/lib/license_finder/license/isc.rb +0 -3
- data/lib/license_finder/license/lgpl.rb +0 -4
- data/lib/license_finder/license/mit.rb +0 -23
- data/lib/license_finder/license/new_bsd.rb +0 -27
- data/lib/license_finder/license/python.rb +0 -8
- data/lib/license_finder/license/ruby.rb +0 -11
- data/lib/license_finder/license/simplified_bsd.rb +0 -8
- data/lib/license_finder/railtie.rb +0 -7
- data/lib/tasks/license_finder.rake +0 -7
- data/spec/lib/license_finder/license/apache_spec.rb +0 -7
- data/spec/lib/license_finder/license/bsd_spec.rb +0 -41
- data/spec/lib/license_finder/license/gplv2_spec.rb +0 -7
- data/spec/lib/license_finder/license/isc_spec.rb +0 -7
- data/spec/lib/license_finder/license/lgpl_spec.rb +0 -7
- data/spec/lib/license_finder/license/mit_spec.rb +0 -33
- data/spec/lib/license_finder/license/python_spec.rb +0 -7
- data/spec/lib/license_finder/license/ruby_spec.rb +0 -19
- data/spec/lib/license_finder/license/simplified_bsd_spec.rb +0 -7
- data/spec/lib/license_finder/reporter_spec.rb +0 -46
- data/spec/support/license_examples.rb +0 -30
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module LicenseFinder
|
4
|
+
describe MavenPackage do
|
5
|
+
subject do
|
6
|
+
described_class.new(
|
7
|
+
{
|
8
|
+
"groupId" => "org.hamcrest",
|
9
|
+
"artifactId" => "hamcrest-core",
|
10
|
+
"version" => "4.11",
|
11
|
+
"licenses" => [{
|
12
|
+
"name" => "Common Public License Version 1.0",
|
13
|
+
"url" => "http://www.opensource.org/licenses/cpl1.0.txt"
|
14
|
+
}]
|
15
|
+
}
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
it_behaves_like "it conforms to interface required by PackageSaver"
|
20
|
+
|
21
|
+
its(:name) { should == "hamcrest-core" }
|
22
|
+
its(:version) { should == "4.11" }
|
23
|
+
its(:description) { should == "" }
|
24
|
+
its(:licenses_from_spec) { should == ["Common Public License Version 1.0"] }
|
25
|
+
|
26
|
+
describe "#license" do
|
27
|
+
it "returns the license if found" do
|
28
|
+
subject.license.should == "Common Public License Version 1.0"
|
29
|
+
end
|
30
|
+
|
31
|
+
context "when there are multiple licenses" do
|
32
|
+
subject do
|
33
|
+
described_class.new(
|
34
|
+
{
|
35
|
+
"groupId" => "org.hamcrest",
|
36
|
+
"artifactId" => "hamcrest-core",
|
37
|
+
"licenses" => [{
|
38
|
+
"name" => "Common Public License Version 1.0",
|
39
|
+
"url" => "http://www.opensource.org/licenses/cpl1.0.txt"
|
40
|
+
},
|
41
|
+
{
|
42
|
+
"name" => "Apache 2",
|
43
|
+
"url" => "http://www.apache.org/licenses/LICENSE-2.0.txt"
|
44
|
+
}]
|
45
|
+
}
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "returns 'other'" do
|
50
|
+
subject.license.should == 'other'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "when the license is not found" do
|
55
|
+
subject do
|
56
|
+
described_class.new(
|
57
|
+
{
|
58
|
+
"groupId" => "org.hamcrest",
|
59
|
+
"artifactId" => "hamcrest-core",
|
60
|
+
"licenses" => {}
|
61
|
+
}
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "returns 'other' otherwise" do
|
66
|
+
subject.license.should == "other"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module LicenseFinder
|
4
|
+
describe Maven do
|
5
|
+
def license_xml(xml)
|
6
|
+
<<-resp
|
7
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
8
|
+
<licenseSummary>
|
9
|
+
<dependencies>
|
10
|
+
#{xml}
|
11
|
+
</dependencies>
|
12
|
+
</licenseSummary>
|
13
|
+
resp
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.current_packages' do
|
17
|
+
before do
|
18
|
+
expect(described_class).to receive(:`).with(/mvn/)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'lists all the current packages' do
|
22
|
+
license_xml = license_xml("""
|
23
|
+
<dependency>
|
24
|
+
<groupId>junit</groupId>
|
25
|
+
<artifactId>junit</artifactId>
|
26
|
+
<version>4.11</version>
|
27
|
+
<licenses>
|
28
|
+
<license>
|
29
|
+
<name>Common Public License Version 1.0</name>
|
30
|
+
<url>http://www.opensource.org/licenses/cpl1.0.txt</url>
|
31
|
+
</license>
|
32
|
+
</licenses>
|
33
|
+
</dependency>
|
34
|
+
<dependency>
|
35
|
+
<groupId>org.hamcrest</groupId>
|
36
|
+
<artifactId>hamcrest-core</artifactId>
|
37
|
+
<version>1.3</version>
|
38
|
+
<licenses>
|
39
|
+
<license>
|
40
|
+
<name>New BSD License</name>
|
41
|
+
<url>http://www.opensource.org/licenses/bsd-license.php</url>
|
42
|
+
<distribution>repo</distribution>
|
43
|
+
</license>
|
44
|
+
</licenses>
|
45
|
+
</dependency>
|
46
|
+
""")
|
47
|
+
allow(File).to receive(:read).with("target/generated-resources/licenses.xml").and_return(license_xml)
|
48
|
+
|
49
|
+
current_packages = Maven.current_packages
|
50
|
+
|
51
|
+
expect(current_packages.size).to eq(2)
|
52
|
+
expect(current_packages.first).to be_a(Package)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "handles multiple licenses" do
|
56
|
+
license_xml = license_xml("""
|
57
|
+
<dependency>
|
58
|
+
<licenses>
|
59
|
+
<license>
|
60
|
+
<name>License 1</name>
|
61
|
+
</license>
|
62
|
+
<license>
|
63
|
+
<name>License 2</name>
|
64
|
+
</license>
|
65
|
+
</licenses>
|
66
|
+
</dependency>
|
67
|
+
""")
|
68
|
+
|
69
|
+
allow(File).to receive(:read).with("target/generated-resources/licenses.xml").and_return(license_xml)
|
70
|
+
|
71
|
+
MavenPackage.should_receive(:new).with("licenses" => [{"name" => "License 1"}, {"name" => "License 2"}])
|
72
|
+
Maven.current_packages
|
73
|
+
end
|
74
|
+
|
75
|
+
it "handles no licenses" do
|
76
|
+
license_xml = license_xml("""
|
77
|
+
<dependency>
|
78
|
+
<licenses>
|
79
|
+
<!-- comment -->
|
80
|
+
</licenses>
|
81
|
+
</dependency>
|
82
|
+
""")
|
83
|
+
|
84
|
+
allow(File).to receive(:read).with("target/generated-resources/licenses.xml").and_return(license_xml)
|
85
|
+
|
86
|
+
MavenPackage.should_receive(:new).with("licenses" => {})
|
87
|
+
Maven.current_packages
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '.active?' do
|
92
|
+
let(:package) { Pathname.new('pom.xml').expand_path }
|
93
|
+
|
94
|
+
context 'with a pom.xml file' do
|
95
|
+
before :each do
|
96
|
+
allow(File).to receive(:exists?).with(package).and_return(true)
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'returns true' do
|
100
|
+
expect(Maven.active?).to eq(true)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'without a pom.xml file' do
|
105
|
+
before :each do
|
106
|
+
allow(File).to receive(:exists?).with(package).and_return(false)
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'returns false' do
|
110
|
+
expect(Maven.active?).to eq(false)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -28,14 +28,16 @@ module LicenseFinder
|
|
28
28
|
PossibleLicenseFiles.stub(:find).with("some/node/package/path").and_return(license_files)
|
29
29
|
end
|
30
30
|
|
31
|
-
let(:node_module1) { {"license" => "MIT"} }
|
32
|
-
let(:node_module2) { {"licenses" => [{"type" => "BSD"}]} }
|
33
|
-
let(:node_module3) { {"license" => {"type" => "PSF"}} }
|
31
|
+
let(:node_module1) { {"license" => "MIT", "path" => "/some/path"} }
|
32
|
+
let(:node_module2) { {"licenses" => [{"type" => "BSD"}], "path" => "/some/path"} }
|
33
|
+
let(:node_module3) { {"license" => {"type" => "PSF"}, "path" => "/some/path"} }
|
34
|
+
let(:node_module4) { {"licenses" => ["MIT"], "path" => "/some/path"} }
|
34
35
|
|
35
36
|
it 'finds the license for both license structures' do
|
36
37
|
NpmPackage.new(node_module1).license.should eq("MIT")
|
37
38
|
NpmPackage.new(node_module2).license.should eq("BSD")
|
38
39
|
NpmPackage.new(node_module3).license.should eq("PSF")
|
40
|
+
NpmPackage.new(node_module4).license.should eq("MIT")
|
39
41
|
end
|
40
42
|
|
41
43
|
it "returns a license in a file if detected" do
|
@@ -44,6 +46,18 @@ module LicenseFinder
|
|
44
46
|
subject.license.should == "Detected License"
|
45
47
|
end
|
46
48
|
|
49
|
+
it "returns other if there's more than one license" do
|
50
|
+
package = NpmPackage.new({ "licenses" => ["MIT", "BSD"], "path" => "/some/path" })
|
51
|
+
expect(package.license).to eq("other")
|
52
|
+
end
|
53
|
+
|
54
|
+
it "returns other if the license from spec and license from files are different" do
|
55
|
+
stub_license_files [double(:file, license: 'Detected License')]
|
56
|
+
package = NpmPackage.new({ "licenses" => ["MIT"], "path" => "some/node/package/path" })
|
57
|
+
|
58
|
+
expect(package.license).to eq("other")
|
59
|
+
end
|
60
|
+
|
47
61
|
it "returns 'other' otherwise" do
|
48
62
|
stub_license_files []
|
49
63
|
|
@@ -50,7 +50,7 @@ module LicenseFinder
|
|
50
50
|
end
|
51
51
|
|
52
52
|
describe '#license' do
|
53
|
-
describe "with pypi license" do
|
53
|
+
describe "with valid pypi license" do
|
54
54
|
it "returns the license from 'license' preferentially" do
|
55
55
|
data = { "license" => "MIT", "classifiers" => [ 'License :: OSI Approved :: Apache 2.0 License' ] }
|
56
56
|
|
@@ -59,15 +59,37 @@ module LicenseFinder
|
|
59
59
|
expect(subject.license).to eq('MIT')
|
60
60
|
end
|
61
61
|
|
62
|
-
|
63
|
-
|
62
|
+
context "when there's no explicit license" do
|
63
|
+
it "returns the license from the 'classifiers' if there is only one" do
|
64
|
+
data = { "classifiers" => [ 'License :: OSI Approved :: Apache 2.0 License' ] }
|
64
65
|
|
65
|
-
|
66
|
+
subject = make_package(data)
|
67
|
+
|
68
|
+
expect(subject.license).to eq('Apache 2.0 License')
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns 'other' if there is are multiple licenses in 'classifiers'" do
|
72
|
+
data = { "classifiers" => [ 'License :: OSI Approved :: Apache 2.0 License', 'License :: OSI Approved :: GPL' ] }
|
73
|
+
|
74
|
+
subject = make_package(data)
|
75
|
+
|
76
|
+
expect(subject.license).to eq('other')
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
context "with UNKNOWN license" do
|
82
|
+
it "returns the license from the classifier if it exists" do
|
83
|
+
data = { "license" => "UNKNOWN", "classifiers" => [ 'License :: OSI Approved :: Apache 2.0 License' ] }
|
66
84
|
|
67
|
-
|
85
|
+
subject = make_package(data)
|
86
|
+
|
87
|
+
expect(subject.license).to eq('Apache 2.0 License')
|
88
|
+
end
|
68
89
|
end
|
69
90
|
end
|
70
91
|
|
92
|
+
|
71
93
|
describe "without pypi license" do
|
72
94
|
def stub_license_files(license_files)
|
73
95
|
PossibleLicenseFiles.stub(:find).with("jasmine/install/path").and_return(license_files)
|
@@ -10,7 +10,7 @@ describe LicenseFinder::PossibleLicenseFile do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
its(:file_path) { should == 'nested/path' }
|
13
|
-
its(:text) { should == 'file text' }
|
13
|
+
its(:text) { should == 'file text' } # this is a terrible test, considering the stubbing
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -20,7 +20,7 @@ describe LicenseFinder::PossibleLicenseFile do
|
|
20
20
|
before do
|
21
21
|
subject.stub(:text).and_return('a known license')
|
22
22
|
|
23
|
-
LicenseFinder::License
|
23
|
+
LicenseFinder::License.stub(:find_by_text).with('a known license').and_return(LicenseFinder::License.find_by_name("MIT"))
|
24
24
|
end
|
25
25
|
|
26
26
|
its(:license) { should == "MIT" }
|
data/spec/lib/license_finder/{detailed_text_report_spec.rb → reports/detailed_text_report_spec.rb}
RENAMED
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module LicenseFinder
|
4
|
+
describe Reporter do
|
5
|
+
describe "#write_reports" do
|
6
|
+
subject { Reporter.write_reports }
|
7
|
+
|
8
|
+
before do
|
9
|
+
Dependency.stub(:all) { [double(:dep)] }
|
10
|
+
|
11
|
+
MarkdownReport.stub(:of) { 'markdown report' }
|
12
|
+
DetailedTextReport.stub(:of) { 'detailed csv report' }
|
13
|
+
TextReport.stub(:of) { 'csv report' }
|
14
|
+
HtmlReport.stub(:of) { 'html report' }
|
15
|
+
end
|
16
|
+
|
17
|
+
it "writes an html file" do
|
18
|
+
subject
|
19
|
+
LicenseFinder.config.artifacts.text_file.read.should == "csv report\n"
|
20
|
+
LicenseFinder.config.artifacts.detailed_text_file.read.should == "detailed csv report\n"
|
21
|
+
LicenseFinder.config.artifacts.markdown_file.read.should == "markdown report\n"
|
22
|
+
LicenseFinder.config.artifacts.html_file.read.should == "html report\n"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "deletes old dependencies.txt file" do
|
26
|
+
fake_file = double(:fake_file, :exist? => true)
|
27
|
+
LicenseFinder.config.artifacts.stub(:legacy_text_file) { fake_file }
|
28
|
+
fake_file.should_receive(:delete)
|
29
|
+
subject
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
File without changes
|
@@ -3,11 +3,10 @@ require 'spec_helper'
|
|
3
3
|
module LicenseFinder
|
4
4
|
describe Dependency do
|
5
5
|
describe '.unapproved' do
|
6
|
-
let(:config) { Configuration.new }
|
6
|
+
let(:config) { Configuration.new('whitelist' => ['MIT', 'other']) }
|
7
7
|
|
8
8
|
before do
|
9
9
|
LicenseFinder.stub(:config).and_return config
|
10
|
-
config.whitelist = ["MIT", "other"]
|
11
10
|
end
|
12
11
|
|
13
12
|
it "should return all unapproved dependencies" do
|
@@ -11,11 +11,10 @@ module LicenseFinder
|
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "#whitelisted?" do
|
14
|
-
let(:config) { Configuration.new }
|
14
|
+
let(:config) { Configuration.new('whitelist' => ['MIT', 'other']) }
|
15
15
|
|
16
16
|
before do
|
17
17
|
LicenseFinder.stub(:config).and_return config
|
18
|
-
config.whitelist = ["MIT", "other"]
|
19
18
|
end
|
20
19
|
|
21
20
|
it "should return true when the license is whitelisted" do
|
@@ -20,31 +20,30 @@ describe LicenseFinder::YmlToSql do
|
|
20
20
|
'license_files' => ['/Users/pivotal/foo/lic1', '/Users/pivotal/bar/lic2'],
|
21
21
|
}
|
22
22
|
end
|
23
|
-
let(:config) { LicenseFinder::Configuration.new }
|
24
23
|
let(:source) { nil }
|
25
24
|
|
26
|
-
before do
|
27
|
-
LicenseFinder.stub(:config) { config }
|
28
|
-
end
|
29
|
-
|
30
25
|
describe ".needs_conversion?" do
|
31
26
|
it "is true if the yml still exists" do
|
32
|
-
|
33
|
-
|
27
|
+
yaml_file = double(:yaml_file, :exist? => true)
|
28
|
+
LicenseFinder.config.artifacts.stub(legacy_yaml_file: yaml_file)
|
29
|
+
|
34
30
|
described_class.needs_conversion?.should be_true
|
35
31
|
end
|
36
32
|
|
37
33
|
it "is false otherwise" do
|
38
|
-
|
39
|
-
|
34
|
+
yaml_file = double(:yaml_file, :exist? => false)
|
35
|
+
LicenseFinder.config.artifacts.stub(legacy_yaml_file: yaml_file)
|
36
|
+
|
40
37
|
described_class.needs_conversion?.should be_false
|
41
38
|
end
|
42
39
|
end
|
43
40
|
|
44
41
|
describe ".remove_yml" do
|
45
42
|
it "removes the yml file" do
|
46
|
-
|
47
|
-
|
43
|
+
yaml_file = double(:yaml_file)
|
44
|
+
LicenseFinder.config.artifacts.stub(legacy_yaml_file: yaml_file)
|
45
|
+
|
46
|
+
yaml_file.should_receive(:delete)
|
48
47
|
described_class.remove_yml
|
49
48
|
end
|
50
49
|
end
|
@@ -2,81 +2,15 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe LicenseFinder do
|
4
4
|
describe ".config" do
|
5
|
-
let(:config) do
|
6
|
-
{
|
7
|
-
'whitelist' => %w(MIT Apache),
|
8
|
-
'ignore_groups' => %w(test development)
|
9
|
-
}
|
10
|
-
end
|
11
|
-
|
12
|
-
before do
|
13
|
-
LicenseFinder.instance_variable_set(:@config, nil)
|
14
|
-
File.stub(:exists?).with('./config/license_finder.yml').and_return(true)
|
15
|
-
File.stub(:read).with('./config/license_finder.yml').and_return(config.to_yaml)
|
16
|
-
end
|
17
|
-
|
18
|
-
after do
|
19
|
-
LicenseFinder.instance_variable_set(:@config, nil)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should handle a missing configuration file" do
|
23
|
-
File.stub(:exists?).with('./config/license_finder.yml').and_return(false)
|
24
|
-
File.should_not_receive(:open).with('./config/license_finder.yml')
|
25
|
-
|
26
|
-
LicenseFinder.config.whitelist.should == []
|
27
|
-
LicenseFinder.config.ignore_groups.should == []
|
28
|
-
LicenseFinder.config.dependencies_dir.should == './doc/'
|
29
|
-
end
|
30
|
-
|
31
5
|
it "should load the configuration exactly once" do
|
32
|
-
|
33
|
-
|
34
|
-
LicenseFinder.config.whitelist
|
35
|
-
LicenseFinder.config.whitelist
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "#whitelist" do
|
39
|
-
it "should load a whitelist from license_finder.yml" do
|
40
|
-
LicenseFinder.config.whitelist.should =~ %w(MIT Apache)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should load an empty whitelist from license_finder.yml when there are no whitelist items" do
|
44
|
-
File.stub(:read).with('./config/license_finder.yml').and_return(config.merge('whitelist' => nil).to_yaml)
|
45
|
-
|
46
|
-
LicenseFinder.config.whitelist.should =~ []
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "#ignore_groups" do
|
51
|
-
it "should load a ignore_groups list from license_finder.yml" do
|
52
|
-
LicenseFinder.config.ignore_groups.should == ["test", "development"]
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should load an empty ignore_groups list from license_finder.yml when there are no ignore groups" do
|
56
|
-
File.stub(:read).with('./config/license_finder.yml').and_return(config.merge('ignore_groups' => nil).to_yaml)
|
57
|
-
|
58
|
-
LicenseFinder.config.ignore_groups.should == []
|
59
|
-
end
|
60
|
-
end
|
6
|
+
LicenseFinder.instance_variable_set(:@config, nil)
|
61
7
|
|
62
|
-
|
63
|
-
it 'should allow the dependencies file directory to be configured' do
|
64
|
-
File.stub(:read).with('./config/license_finder.yml').and_return(config.merge('dependencies_file_dir' => './elsewhere').to_yaml)
|
8
|
+
LicenseFinder::Configuration.should_receive(:ensure_default).once.and_return(double(:config))
|
65
9
|
|
66
|
-
|
67
|
-
|
68
|
-
config.dependencies_yaml.should == './elsewhere/dependencies.yml'
|
69
|
-
config.dependencies_text.should == './elsewhere/dependencies.csv'
|
70
|
-
config.dependencies_html.should == './elsewhere/dependencies.html'
|
71
|
-
end
|
10
|
+
LicenseFinder.config
|
11
|
+
LicenseFinder.config
|
72
12
|
|
73
|
-
|
74
|
-
config = LicenseFinder.config
|
75
|
-
config.dependencies_dir.should == './doc/'
|
76
|
-
config.dependencies_yaml.should == './doc/dependencies.yml'
|
77
|
-
config.dependencies_text.should == './doc/dependencies.csv'
|
78
|
-
config.dependencies_html.should == './doc/dependencies.html'
|
79
|
-
end
|
13
|
+
LicenseFinder.instance_variable_set(:@config, nil)
|
80
14
|
end
|
81
15
|
end
|
82
16
|
end
|