license_finder 1.1.1-java → 1.2-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.rdoc +10 -0
- data/Gemfile +1 -1
- data/README.md +363 -0
- data/Rakefile +30 -1
- data/TODO.md +28 -0
- data/bin/license_finder_pip.py +18 -0
- data/db/migrate/201410031451_rename_dependency_license_name.rb +6 -0
- data/features/multiple_licenses.feature +9 -0
- data/features/step_definitions/cli_steps.rb +9 -9
- data/features/step_definitions/cocoapod_steps.rb +1 -1
- data/features/step_definitions/configure_bundler_groups_steps.rb +3 -3
- data/features/step_definitions/configure_whitelist_steps.rb +4 -4
- data/features/step_definitions/gradle_steps.rb +1 -1
- data/features/step_definitions/manually_added_steps.rb +3 -3
- data/features/step_definitions/manually_approved_steps.rb +5 -5
- data/features/step_definitions/manually_assigned_license_steps.rb +4 -4
- data/features/step_definitions/maven_steps.rb +1 -1
- data/features/step_definitions/multiple_licenses_steps.rb +14 -0
- data/features/step_definitions/node_steps.rb +1 -1
- data/features/step_definitions/python_steps.rb +1 -1
- data/features/step_definitions/report_csv_steps.rb +3 -3
- data/features/step_definitions/report_html_steps.rb +5 -5
- data/features/step_definitions/shared_steps.rb +23 -6
- data/lib/license_finder.rb +3 -0
- data/lib/license_finder/cli.rb +13 -34
- data/lib/license_finder/configuration.rb +8 -4
- data/lib/license_finder/dependency_manager.rb +25 -15
- data/lib/license_finder/license.rb +8 -0
- data/lib/license_finder/logger.rb +59 -0
- data/lib/license_finder/package.rb +37 -30
- data/lib/license_finder/package_manager.rb +20 -0
- data/lib/license_finder/package_managers/bower.rb +4 -9
- data/lib/license_finder/package_managers/bower_package.rb +2 -1
- data/lib/license_finder/package_managers/bundler.rb +26 -41
- data/lib/license_finder/package_managers/bundler_package.rb +6 -3
- data/lib/license_finder/package_managers/cocoa_pods.rb +18 -10
- data/lib/license_finder/package_managers/cocoa_pods_package.rb +4 -3
- data/lib/license_finder/package_managers/gradle.rb +7 -11
- data/lib/license_finder/package_managers/gradle_package.rb +2 -7
- data/lib/license_finder/package_managers/maven.rb +5 -9
- data/lib/license_finder/package_managers/maven_package.rb +4 -8
- data/lib/license_finder/package_managers/npm.rb +6 -10
- data/lib/license_finder/package_managers/npm_package.rb +2 -1
- data/lib/license_finder/package_managers/pip.rb +11 -24
- data/lib/license_finder/package_managers/pip_package.rb +2 -1
- data/lib/license_finder/package_saver.rb +2 -2
- data/lib/license_finder/platform.rb +4 -0
- data/lib/license_finder/possible_license_file.rb +4 -0
- data/lib/license_finder/possible_license_files.rb +2 -1
- data/lib/license_finder/reports/detailed_text_report.rb +1 -1
- data/lib/license_finder/reports/formatted_report.rb +1 -1
- data/lib/license_finder/tables/dependency.rb +22 -12
- data/lib/license_finder/yml_to_sql.rb +1 -1
- data/lib/templates/html_report.erb +4 -4
- data/lib/templates/markdown_report.erb +4 -4
- data/lib/templates/text_report.erb +1 -1
- data/license_finder.gemspec +28 -12
- data/spec/lib/license_finder/cli_spec.rb +193 -185
- data/spec/lib/license_finder/configuration_spec.rb +46 -47
- data/spec/lib/license_finder/dependency_manager_spec.rb +48 -44
- data/spec/lib/license_finder/license/definitions_spec.rb +26 -26
- data/spec/lib/license_finder/license_spec.rb +25 -25
- data/spec/lib/license_finder/package_managers/bower_package_spec.rb +33 -17
- data/spec/lib/license_finder/package_managers/bower_spec.rb +35 -35
- data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +20 -15
- data/spec/lib/license_finder/package_managers/bundler_spec.rb +12 -19
- data/spec/lib/license_finder/package_managers/cocoa_pods_package_spec.rb +8 -5
- data/spec/lib/license_finder/package_managers/cocoa_pods_spec.rb +20 -22
- data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +8 -5
- data/spec/lib/license_finder/package_managers/gradle_spec.rb +20 -20
- data/spec/lib/license_finder/package_managers/maven_package_spec.rb +8 -5
- data/spec/lib/license_finder/package_managers/maven_spec.rb +18 -18
- data/spec/lib/license_finder/package_managers/npm_package_spec.rb +36 -17
- data/spec/lib/license_finder/package_managers/npm_spec.rb +17 -17
- data/spec/lib/license_finder/package_managers/pip_package_spec.rb +16 -10
- data/spec/lib/license_finder/package_managers/pip_spec.rb +21 -18
- data/spec/lib/license_finder/package_saver_spec.rb +15 -25
- data/spec/lib/license_finder/possible_license_file_spec.rb +5 -4
- data/spec/lib/license_finder/possible_license_files_spec.rb +11 -5
- data/spec/lib/license_finder/reports/detailed_text_report_spec.rb +3 -3
- data/spec/lib/license_finder/reports/html_report_spec.rb +23 -23
- data/spec/lib/license_finder/reports/markdown_report_spec.rb +12 -12
- data/spec/lib/license_finder/reports/reporter_spec.rb +11 -11
- data/spec/lib/license_finder/reports/text_report_spec.rb +3 -3
- data/spec/lib/license_finder/tables/dependency_spec.rb +59 -41
- data/spec/lib/license_finder/yml_to_sql_spec.rb +21 -21
- data/spec/lib/license_finder_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -13
- data/spec/support/shared_examples_for_package.rb +46 -0
- data/spec/support/shared_examples_for_package_manager.rb +15 -0
- metadata +19 -100
- data/readme.md +0 -259
@@ -4,7 +4,7 @@ module LicenseFinder
|
|
4
4
|
describe License do
|
5
5
|
describe ".find_by_name" do
|
6
6
|
it "should find a registered license" do
|
7
|
-
License.find_by_name("Apache2").
|
7
|
+
expect(License.find_by_name("Apache2")).to be_a License
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should make an unrecognized license" do
|
@@ -16,20 +16,20 @@ module LicenseFinder
|
|
16
16
|
|
17
17
|
context "making the default license" do
|
18
18
|
it "set the name to 'other'" do
|
19
|
-
License.find_by_name(nil).name.
|
19
|
+
expect(License.find_by_name(nil).name).to eq("other")
|
20
20
|
end
|
21
21
|
|
22
22
|
it "does not equal other uses of the default license" do
|
23
|
-
License.find_by_name(nil).
|
23
|
+
expect(License.find_by_name(nil)).not_to eq(License.find_by_name(nil))
|
24
24
|
end
|
25
25
|
|
26
26
|
context "when there is a whitelist" do
|
27
27
|
before do
|
28
|
-
LicenseFinder.config.
|
28
|
+
allow(LicenseFinder.config).to receive(:whitelist).and_return(["not empty"])
|
29
29
|
end
|
30
30
|
|
31
31
|
it "does not blow up" do
|
32
|
-
License.find_by_name(nil).name.
|
32
|
+
expect(License.find_by_name(nil).name).to eq("other")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -37,7 +37,7 @@ module LicenseFinder
|
|
37
37
|
|
38
38
|
describe ".find_by_text" do
|
39
39
|
it "should find a registered license" do
|
40
|
-
License.find_by_text('This gem is released under the MIT license').
|
40
|
+
expect(License.find_by_text('This gem is released under the MIT license')).to be_a License
|
41
41
|
end
|
42
42
|
|
43
43
|
it "returns nil if not found" do
|
@@ -60,51 +60,51 @@ module LicenseFinder
|
|
60
60
|
|
61
61
|
describe "#whitelisted?" do
|
62
62
|
it "is true if the settings say it is" do
|
63
|
-
make_license.
|
64
|
-
make_license(whitelisted: true).
|
63
|
+
expect(make_license).not_to be_whitelisted
|
64
|
+
expect(make_license(whitelisted: true)).to be_whitelisted
|
65
65
|
end
|
66
66
|
|
67
67
|
it "can be made true (without mutating original)" do
|
68
68
|
original = make_license
|
69
69
|
license = original.whitelist
|
70
|
-
license.
|
71
|
-
license.
|
72
|
-
license.url.
|
73
|
-
license.
|
74
|
-
license.
|
70
|
+
expect(license).not_to eq(original)
|
71
|
+
expect(license).to be_whitelisted
|
72
|
+
expect(license.url).to eq("http://example.com/license")
|
73
|
+
expect(license).to be_matches_name "Default Short Name"
|
74
|
+
expect(license).to be_matches_text "Default Matcher"
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
describe "#matches_name?" do
|
79
79
|
it "should match on short_name" do
|
80
|
-
make_license(short_name: "Foo").
|
80
|
+
expect(make_license(short_name: "Foo")).to be_matches_name "Foo"
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should match on pretty name" do
|
84
|
-
make_license(pretty_name: "Foo").
|
84
|
+
expect(make_license(pretty_name: "Foo")).to be_matches_name "Foo"
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should match on alternative names" do
|
88
88
|
license = make_license(other_names: ["Foo", "Bar"])
|
89
|
-
license.
|
90
|
-
license.
|
89
|
+
expect(license).to be_matches_name "Foo"
|
90
|
+
expect(license).to be_matches_name "Bar"
|
91
91
|
end
|
92
92
|
|
93
93
|
it "should ignore case" do
|
94
|
-
make_license(pretty_name: "Foo").
|
95
|
-
make_license(pretty_name: "foo").
|
94
|
+
expect(make_license(pretty_name: "Foo")).to be_matches_name "foo"
|
95
|
+
expect(make_license(pretty_name: "foo")).to be_matches_name "Foo"
|
96
96
|
end
|
97
97
|
|
98
98
|
it "should not fail if pretty_name or other_names are omitted" do
|
99
|
-
make_license.
|
99
|
+
expect(make_license).to be_matches_name "Default Short Name"
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
103
|
describe ".matches_text?" do
|
104
104
|
it "should match on text" do
|
105
105
|
license = make_license(matcher: License::Matcher.from_regex(/The license text/))
|
106
|
-
license.
|
107
|
-
license.
|
106
|
+
expect(license).to be_matches_text "The license text"
|
107
|
+
expect(license).not_to be_matches_text "Some other text"
|
108
108
|
end
|
109
109
|
|
110
110
|
it "should match regardless of placeholder names, whitespace, or quotes" do
|
@@ -114,7 +114,7 @@ module LicenseFinder
|
|
114
114
|
LICENSE
|
115
115
|
license = make_license(matcher: License::Matcher.from_text(License::Text.normalize_punctuation(license_text)))
|
116
116
|
|
117
|
-
license.
|
117
|
+
expect(license).to be_matches_text <<-FILE
|
118
118
|
The ''company'' of foo bar *%*%*%*%
|
119
119
|
shall not be held "responsible" for `anything`.
|
120
120
|
FILE
|
@@ -123,12 +123,12 @@ module LicenseFinder
|
|
123
123
|
it "should match even if whitespace at beginning and end don't match" do
|
124
124
|
template = License::Template.new("\nThe license text")
|
125
125
|
license = make_license(matcher: License::Matcher.from_template(template))
|
126
|
-
license.
|
126
|
+
expect(license).to be_matches_text "The license text\n"
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
130
|
it "should default pretty_name to short_name" do
|
131
|
-
make_license.name.
|
131
|
+
expect(make_license.name).to eq("Default Short Name")
|
132
132
|
end
|
133
133
|
end
|
134
134
|
end
|
@@ -16,7 +16,7 @@ module LicenseFinder
|
|
16
16
|
)
|
17
17
|
end
|
18
18
|
|
19
|
-
it_behaves_like "
|
19
|
+
it_behaves_like "a Package"
|
20
20
|
|
21
21
|
its(:name) { should == "dependency-library" }
|
22
22
|
its(:version) { should == "1.3.3.7" }
|
@@ -26,9 +26,9 @@ module LicenseFinder
|
|
26
26
|
its(:groups) { should == [] }
|
27
27
|
its(:children) { should == [] }
|
28
28
|
|
29
|
-
describe '#
|
29
|
+
describe '#licenses' do
|
30
30
|
def stub_license_files(license_files)
|
31
|
-
PossibleLicenseFiles.
|
31
|
+
allow(PossibleLicenseFiles).to receive(:find).with("/path/to/thing").and_return(license_files)
|
32
32
|
end
|
33
33
|
|
34
34
|
let(:package1) { { "pkgMeta" => {"license" => "MIT"}, "canonicalDir" => "/some/path" } }
|
@@ -37,52 +37,68 @@ module LicenseFinder
|
|
37
37
|
let(:package4) { { "pkgMeta" => {"licenses" => ["MIT"]}, "canonicalDir" => "/some/path" } }
|
38
38
|
|
39
39
|
it 'finds the license for both license structures' do
|
40
|
-
BowerPackage.new(package1)
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
package = BowerPackage.new(package1)
|
41
|
+
expect(package.licenses.length).to eq 1
|
42
|
+
expect(package.licenses.first.name).to eq("MIT")
|
43
|
+
|
44
|
+
package = BowerPackage.new(package2)
|
45
|
+
expect(package.licenses.length).to eq 1
|
46
|
+
expect(package.licenses.first.name).to eq("BSD")
|
47
|
+
|
48
|
+
package = BowerPackage.new(package3)
|
49
|
+
expect(package.licenses.length).to eq 1
|
50
|
+
expect(package.licenses.first.name).to eq("Python Software Foundation License")
|
51
|
+
|
52
|
+
package = BowerPackage.new(package4)
|
53
|
+
expect(package.licenses.length).to eq 1
|
54
|
+
expect(package.licenses.first.name).to eq("MIT")
|
44
55
|
end
|
45
56
|
|
46
57
|
|
47
58
|
context "regardless of whether there are licenses in files" do
|
48
59
|
before do
|
49
|
-
stub_license_files [double(:file, license: License.find_by_name('Detected License'))]
|
60
|
+
stub_license_files [double(:file, license: License.find_by_name('Detected License'), path: "/")]
|
50
61
|
end
|
51
62
|
|
52
63
|
it "returns the license from the spec if there is only one unique license" do
|
53
64
|
package = BowerPackage.new({ "pkgMeta" => {"licenses" => ["MIT", "Expat"]}, "canonicalDir" => "/path/to/thing" })
|
54
|
-
expect(package.
|
65
|
+
expect(package.licenses.length).to eq 1
|
66
|
+
expect(package.licenses.first.name).to eq("MIT")
|
55
67
|
end
|
56
68
|
|
57
69
|
it "returns 'multiple licenses' if there's more than one license" do
|
58
70
|
package = BowerPackage.new({ "pkgMeta" => {"licenses" => ["MIT", "BSD"]}, "canonicalDir" => "/some/path" })
|
59
|
-
expect(package.
|
71
|
+
expect(package.licenses.length).to eq 2
|
72
|
+
expect(package.licenses.map(&:name)).to eq %w(MIT BSD)
|
60
73
|
end
|
61
74
|
end
|
62
75
|
|
63
76
|
context "when there is nothing in the spec" do
|
64
77
|
it "returns a license in a file if only one unique license detected" do
|
65
78
|
stub_license_files([
|
66
|
-
double(:first_file, license: License.find_by_name('MIT')),
|
67
|
-
double(:second_file, license: License.find_by_name('Expat'))
|
79
|
+
double(:first_file, license: License.find_by_name('MIT'), path: "/"),
|
80
|
+
double(:second_file, license: License.find_by_name('Expat'), path: "/")
|
68
81
|
])
|
69
82
|
|
70
|
-
subject.
|
83
|
+
expect(subject.licenses.length).to eq 1
|
84
|
+
expect(subject.licenses.first.name).to eq "MIT"
|
71
85
|
end
|
72
86
|
|
73
87
|
it "returns 'other' if there are no licenses in files" do
|
74
88
|
stub_license_files []
|
75
89
|
|
76
|
-
subject.
|
90
|
+
expect(subject.licenses.length).to eq 1
|
91
|
+
expect(subject.licenses.first.name).to eq "other"
|
77
92
|
end
|
78
93
|
|
79
94
|
it "returns 'other' if there are many licenses in files" do
|
80
95
|
stub_license_files([
|
81
|
-
double(:first_file, license: License.find_by_name('First Detected License')),
|
82
|
-
double(:second_file, license: License.find_by_name('Second Detected License'))
|
96
|
+
double(:first_file, license: License.find_by_name('First Detected License'), path: "/"),
|
97
|
+
double(:second_file, license: License.find_by_name('Second Detected License'), path: "/")
|
83
98
|
])
|
84
99
|
|
85
|
-
subject.
|
100
|
+
expect(subject.licenses.length).to eq 2
|
101
|
+
expect(subject.licenses.map(&:name)).to eq ["First Detected License", "Second Detected License"]
|
86
102
|
end
|
87
103
|
end
|
88
104
|
end
|
@@ -2,35 +2,38 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module LicenseFinder
|
4
4
|
describe Bower do
|
5
|
+
let(:bower) { Bower.new }
|
6
|
+
it_behaves_like "a PackageManager"
|
7
|
+
|
5
8
|
describe '.current_packages' do
|
6
9
|
it 'lists all the current packages' do
|
7
|
-
json = <<-
|
8
|
-
{
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
}
|
30
|
-
|
31
|
-
allow(
|
10
|
+
json = <<-JSON
|
11
|
+
{
|
12
|
+
"dependencies": {
|
13
|
+
"dependency-library": {
|
14
|
+
"canonicalDir": "/path/to/thing",
|
15
|
+
"pkgMeta": {
|
16
|
+
"name": "dependency-library",
|
17
|
+
"description": "description",
|
18
|
+
"version": "1.3.3.7",
|
19
|
+
"main": "normalize.css"
|
20
|
+
}
|
21
|
+
},
|
22
|
+
"another-dependency": {
|
23
|
+
"canonicalDir": "/path/to/thing2",
|
24
|
+
"pkgMeta": {
|
25
|
+
"name": "another-dependency",
|
26
|
+
"description": "description2",
|
27
|
+
"version": "4.2",
|
28
|
+
"main": "denormalize.css"
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
JSON
|
34
|
+
allow(bower).to receive("`").with(/bower/).and_return(json)
|
32
35
|
|
33
|
-
current_packages =
|
36
|
+
current_packages = bower.current_packages
|
34
37
|
|
35
38
|
expect(current_packages.size).to eq(2)
|
36
39
|
expect(current_packages.first).to be_a(Package)
|
@@ -38,20 +41,17 @@ module LicenseFinder
|
|
38
41
|
end
|
39
42
|
|
40
43
|
describe '.active?' do
|
41
|
-
let(:
|
42
|
-
|
43
|
-
before do
|
44
|
-
Bower.stub(package_path: package)
|
45
|
-
end
|
44
|
+
let(:package_path) { double(:package_file) }
|
45
|
+
let(:bower) { Bower.new package_path: package_path }
|
46
46
|
|
47
47
|
it 'is true with a bower.json file' do
|
48
|
-
|
49
|
-
expect(
|
48
|
+
allow(package_path).to receive_messages(:exist? => true)
|
49
|
+
expect(bower).to be_active
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'is false without a bower.json file' do
|
53
|
-
|
54
|
-
expect(
|
53
|
+
allow(package_path).to receive_messages(:exist? => false)
|
54
|
+
expect(bower).to_not be_active
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -4,7 +4,7 @@ module LicenseFinder
|
|
4
4
|
describe BundlerPackage do
|
5
5
|
subject { described_class.new(gemspec, nil) }
|
6
6
|
|
7
|
-
it_behaves_like "
|
7
|
+
it_behaves_like "a Package"
|
8
8
|
|
9
9
|
let(:gemspec) do
|
10
10
|
Gem::Specification.new do |s|
|
@@ -24,23 +24,24 @@ module LicenseFinder
|
|
24
24
|
its(:description) { should == "description" }
|
25
25
|
its(:homepage) { should == "homepage" }
|
26
26
|
its(:groups) { should == [] }
|
27
|
-
its(:children) { should == [] }
|
27
|
+
its(:children) { should == ['foo'] }
|
28
28
|
|
29
|
-
describe "#
|
29
|
+
describe "#licenses" do
|
30
30
|
def stub_license_files(license_files)
|
31
|
-
PossibleLicenseFiles.
|
31
|
+
allow(PossibleLicenseFiles).to receive(:find).and_return(license_files)
|
32
32
|
end
|
33
33
|
|
34
34
|
context "regardless of whether there are licenses in files" do
|
35
35
|
before do
|
36
|
-
stub_license_files [double(:file, license: License.find_by_name('Detected License'))]
|
36
|
+
stub_license_files [double(:file, license: License.find_by_name('Detected License'), path: "/")]
|
37
37
|
end
|
38
38
|
|
39
39
|
context 'if the gemspec provides two synonymous licenses' do
|
40
40
|
before { gemspec.licenses = ['MIT', 'Expat'] }
|
41
41
|
|
42
42
|
it 'returns the license only once' do
|
43
|
-
subject.
|
43
|
+
expect(subject.licenses.length).to eq 1
|
44
|
+
expect(subject.licenses.first.name).to eq "MIT"
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
@@ -48,7 +49,8 @@ module LicenseFinder
|
|
48
49
|
before { gemspec.licenses = ['First Gemspec License', 'Second Gemspec License'] }
|
49
50
|
|
50
51
|
it "returns 'multiple licenses' with the names of the licenses from the gemspec (but not those from detected files)" do
|
51
|
-
subject.
|
52
|
+
expect(subject.licenses.length).to eq 2
|
53
|
+
expect(subject.licenses.map(&:name)).to eq ["First Gemspec License", "Second Gemspec License"]
|
52
54
|
end
|
53
55
|
end
|
54
56
|
end
|
@@ -56,26 +58,29 @@ module LicenseFinder
|
|
56
58
|
context "when there is nothing in the spec" do
|
57
59
|
it "returns a license in a file if there is only one unique license detected" do
|
58
60
|
stub_license_files([
|
59
|
-
double(:first_file, license: License.find_by_name('MIT')),
|
60
|
-
double(:second_file, license: License.find_by_name('Expat'))
|
61
|
+
double(:first_file, license: License.find_by_name('MIT'), path: "/"),
|
62
|
+
double(:second_file, license: License.find_by_name('Expat'), path: "/")
|
61
63
|
])
|
62
64
|
|
63
|
-
subject.
|
65
|
+
expect(subject.licenses.length).to eq 1
|
66
|
+
expect(subject.licenses.first.name).to eq "MIT"
|
64
67
|
end
|
65
68
|
|
66
69
|
it "returns 'other' if there are no licenses in files" do
|
67
70
|
stub_license_files []
|
68
71
|
|
69
|
-
subject.
|
72
|
+
expect(subject.licenses.length).to eq 1
|
73
|
+
expect(subject.licenses.first.name).to eq "other"
|
70
74
|
end
|
71
75
|
|
72
76
|
it "returns 'multiple licenses' if there are many licenses in files" do
|
73
77
|
stub_license_files([
|
74
|
-
double(:first_file, license: License.find_by_name('First Detected License')),
|
75
|
-
double(:second_file, license: License.find_by_name('Second Detected License'))
|
78
|
+
double(:first_file, license: License.find_by_name('First Detected License'), path: "/"),
|
79
|
+
double(:second_file, license: License.find_by_name('Second Detected License'), path: "/")
|
76
80
|
])
|
77
81
|
|
78
|
-
subject.
|
82
|
+
expect(subject.licenses.length).to eq 2
|
83
|
+
expect(subject.licenses.map(&:name)).to eq ["First Detected License", "Second Detected License"]
|
79
84
|
end
|
80
85
|
end
|
81
86
|
end
|
@@ -86,7 +91,7 @@ module LicenseFinder
|
|
86
91
|
let(:bundler_dependency) { double(:dependency, groups: [1, 2, 3]) }
|
87
92
|
|
88
93
|
it "returns bundler dependency's groups" do
|
89
|
-
subject.groups.
|
94
|
+
expect(subject.groups).to eq(bundler_dependency.groups)
|
90
95
|
end
|
91
96
|
end
|
92
97
|
end
|
@@ -2,6 +2,8 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
module LicenseFinder
|
4
4
|
describe Bundler do
|
5
|
+
it_behaves_like "a PackageManager"
|
6
|
+
|
5
7
|
let(:definition) do
|
6
8
|
double('definition', {
|
7
9
|
:dependencies => [],
|
@@ -28,16 +30,16 @@ module LicenseFinder
|
|
28
30
|
|
29
31
|
describe '.current_packages' do
|
30
32
|
subject do
|
31
|
-
Bundler.
|
33
|
+
Bundler.new(ignore_groups: ['dev', 'test'], definition: definition).current_packages
|
32
34
|
end
|
33
35
|
|
34
36
|
it "should have 2 dependencies" do
|
35
|
-
subject.size.
|
37
|
+
expect(subject.size).to eq(2)
|
36
38
|
end
|
37
39
|
|
38
40
|
context "when initialized with a parent and child gem" do
|
39
41
|
before do
|
40
|
-
definition.
|
42
|
+
allow(definition).to receive(:specs_for).with([:production]).and_return([
|
41
43
|
build_gemspec('gem1', '1.2.3', 'gem2'),
|
42
44
|
build_gemspec('gem2', '0.4.2', 'gem3')
|
43
45
|
])
|
@@ -46,32 +48,23 @@ module LicenseFinder
|
|
46
48
|
it "should update the child dependency with its parent data" do
|
47
49
|
gem1 = subject.first
|
48
50
|
|
49
|
-
gem1.children.
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should only include the children which are project dependencies" do
|
53
|
-
gem2 = subject[1]
|
54
|
-
|
55
|
-
gem2.children.should == []
|
51
|
+
expect(gem1.children).to eq(["gem2"])
|
56
52
|
end
|
57
53
|
end
|
58
54
|
end
|
59
55
|
|
60
56
|
describe '.active?' do
|
61
|
-
let(:
|
62
|
-
|
63
|
-
before do
|
64
|
-
Bundler.stub(gemfile_path: gemfile)
|
65
|
-
end
|
57
|
+
let(:package_path) { double(:gemfile_file) }
|
58
|
+
let(:bundler) { Bundler.new package_path: package_path }
|
66
59
|
|
67
60
|
it 'is true with a Gemfile file' do
|
68
|
-
|
69
|
-
expect(
|
61
|
+
allow(package_path).to receive_messages(:exist? => true)
|
62
|
+
expect(bundler).to be_active
|
70
63
|
end
|
71
64
|
|
72
65
|
it 'is false without a Gemfile file' do
|
73
|
-
|
74
|
-
expect(
|
66
|
+
allow(package_path).to receive_messages(:exist? => false)
|
67
|
+
expect(bundler).to_not be_active
|
75
68
|
end
|
76
69
|
end
|
77
70
|
end
|