licensee 9.12.0 → 9.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/licensee +3 -3
- data/lib/licensee/commands/detect.rb +5 -5
- data/lib/licensee/content_helper.rb +53 -8
- data/lib/licensee/hash_helper.rb +5 -5
- data/lib/licensee/license.rb +16 -20
- data/lib/licensee/matchers/dice.rb +3 -3
- data/lib/licensee/projects/git_project.rb +3 -3
- data/lib/licensee/projects/project.rb +3 -3
- data/lib/licensee/version.rb +1 -1
- data/licensee.gemspec +47 -0
- data/spec/bin_spec.rb +1 -1
- data/spec/fixture_spec.rb +5 -5
- data/spec/fixtures/cc0-cal2013/LICENSE +116 -0
- data/spec/fixtures/cc0-cc/LICENSE +121 -0
- data/spec/fixtures/detect.json +1 -1
- data/spec/fixtures/fixtures.yml +12 -0
- data/spec/fixtures/license-hashes.json +5 -4
- data/spec/fixtures/unlicense-noinfo/LICENSE +22 -0
- data/spec/integration_spec.rb +30 -2
- data/spec/licensee/commands/detect_spec.rb +4 -4
- data/spec/licensee/commands/license_path_spec.rb +1 -1
- data/spec/licensee/commands/version_spec.rb +1 -1
- data/spec/licensee/content_helper_spec.rb +43 -42
- data/spec/licensee/hash_helper_spec.rb +1 -1
- data/spec/licensee/license_field_spec.rb +3 -3
- data/spec/licensee/license_meta_spec.rb +13 -11
- data/spec/licensee/license_rules_spec.rb +4 -2
- data/spec/licensee/license_spec.rb +33 -33
- data/spec/licensee/matchers/cabal_matcher_spec.rb +4 -2
- data/spec/licensee/matchers/cargo_matcher_spec.rb +3 -2
- data/spec/licensee/matchers/copyright_matcher_spec.rb +3 -3
- data/spec/licensee/matchers/cran_matcher_spec.rb +3 -2
- data/spec/licensee/matchers/dice_matcher_spec.rb +11 -10
- data/spec/licensee/matchers/dist_zilla_matcher_spec.rb +3 -2
- data/spec/licensee/matchers/exact_matcher_spec.rb +3 -2
- data/spec/licensee/matchers/gemspec_matcher_spec.rb +3 -2
- data/spec/licensee/matchers/matcher_spec.rb +4 -2
- data/spec/licensee/matchers/npm_bower_matcher_spec.rb +3 -3
- data/spec/licensee/matchers/package_matcher_spec.rb +4 -2
- data/spec/licensee/matchers/reference_matcher_spec.rb +2 -2
- data/spec/licensee/matchers/spdx_matcher_spec.rb +3 -2
- data/spec/licensee/project_files/license_file_spec.rb +15 -15
- data/spec/licensee/project_files/package_info_spec.rb +3 -1
- data/spec/licensee/project_files/project_file_spec.rb +5 -2
- data/spec/licensee/project_files/readme_file_spec.rb +2 -1
- data/spec/licensee/project_spec.rb +22 -17
- data/spec/licensee/projects/github_project_spec.rb +6 -5
- data/spec/licensee/rule_spec.rb +4 -3
- data/spec/licensee_spec.rb +10 -9
- data/spec/spec_helper.rb +2 -2
- data/spec/vendored_license_spec.rb +3 -3
- data/vendor/choosealicense.com/_data/rules.yml +3 -0
- data/vendor/choosealicense.com/_licenses/bsd-3-clause-clear.txt +1 -0
- data/vendor/choosealicense.com/_licenses/bsd-4-clause.txt +61 -0
- data/vendor/choosealicense.com/_licenses/bsl-1.0.txt +4 -1
- data/vendor/choosealicense.com/_licenses/cc-by-4.0.txt +3 -0
- data/vendor/choosealicense.com/_licenses/cc-by-sa-4.0.txt +3 -0
- data/vendor/choosealicense.com/_licenses/cc0-1.0.txt +112 -103
- data/vendor/choosealicense.com/_licenses/ofl-1.1.txt +3 -0
- data/vendor/choosealicense.com/_licenses/zlib.txt +4 -1
- metadata +37 -4
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Licensee::Matchers::Dice do
|
4
|
+
subject { described_class.new(file) }
|
5
|
+
|
4
6
|
let(:mit) { Licensee::License.find('mit') }
|
5
7
|
let(:gpl) { Licensee::License.find('gpl-3.0') }
|
6
8
|
let(:agpl) { Licensee::License.find('agpl-3.0') }
|
@@ -8,7 +10,6 @@ RSpec.describe Licensee::Matchers::Dice do
|
|
8
10
|
let(:cc_by_sa) { Licensee::License.find('cc-by-sa-4.0') }
|
9
11
|
let(:content) { sub_copyright_info(gpl) }
|
10
12
|
let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.txt') }
|
11
|
-
subject { described_class.new(file) }
|
12
13
|
|
13
14
|
it 'stores the file' do
|
14
15
|
expect(subject.file).to eql(file)
|
@@ -33,16 +34,16 @@ RSpec.describe Licensee::Matchers::Dice do
|
|
33
34
|
end
|
34
35
|
|
35
36
|
it 'returns the match confidence' do
|
36
|
-
expect(subject.confidence).to
|
37
|
+
expect(subject.confidence).to be(100.0)
|
37
38
|
end
|
38
39
|
|
39
40
|
context 'without a match' do
|
40
41
|
let(:content) { 'Not really a license' }
|
41
42
|
|
42
43
|
it "doesn't match" do
|
43
|
-
expect(subject.match).to
|
44
|
+
expect(subject.match).to be(nil)
|
44
45
|
expect(subject.matches).to be_empty
|
45
|
-
expect(subject.confidence).to
|
46
|
+
expect(subject.confidence).to be(0)
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
@@ -52,10 +53,10 @@ RSpec.describe Licensee::Matchers::Dice do
|
|
52
53
|
end
|
53
54
|
|
54
55
|
it "doesn't match" do
|
55
|
-
expect(content).
|
56
|
-
expect(subject.match).to
|
56
|
+
expect(content).not_to be_detected_as(gpl)
|
57
|
+
expect(subject.match).to be(nil)
|
57
58
|
expect(subject.matches).to be_empty
|
58
|
-
expect(subject.confidence).to
|
59
|
+
expect(subject.confidence).to be(0)
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
@@ -74,11 +75,11 @@ RSpec.describe Licensee::Matchers::Dice do
|
|
74
75
|
let(:content) { File.read(license_path) }
|
75
76
|
|
76
77
|
it "doesn't match" do
|
77
|
-
expect(content).
|
78
|
-
expect(content).
|
78
|
+
expect(content).not_to be_detected_as(cc_by)
|
79
|
+
expect(content).not_to be_detected_as(cc_by_sa)
|
79
80
|
expect(subject.match).to be_nil
|
80
81
|
expect(subject.matches).to be_empty
|
81
|
-
expect(subject.confidence).to
|
82
|
+
expect(subject.confidence).to be(0)
|
82
83
|
end
|
83
84
|
end
|
84
85
|
end
|
@@ -1,17 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Licensee::Matchers::DistZilla do
|
4
|
+
subject { described_class.new(file) }
|
5
|
+
|
4
6
|
let(:mit) { Licensee::License.find('mit') }
|
5
7
|
let(:content) { 'license = MIT' }
|
6
8
|
let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'dist.ini') }
|
7
|
-
subject { described_class.new(file) }
|
8
9
|
|
9
10
|
it 'stores the file' do
|
10
11
|
expect(subject.file).to eql(file)
|
11
12
|
end
|
12
13
|
|
13
14
|
it 'has confidence' do
|
14
|
-
expect(subject.confidence).to
|
15
|
+
expect(subject.confidence).to be(90)
|
15
16
|
end
|
16
17
|
|
17
18
|
it 'matches' do
|
@@ -1,10 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Licensee::Matchers::Exact do
|
4
|
+
subject { described_class.new(file) }
|
5
|
+
|
4
6
|
let(:mit) { Licensee::License.find('mit') }
|
5
7
|
let(:content) { sub_copyright_info(mit) }
|
6
8
|
let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.txt') }
|
7
|
-
subject { described_class.new(file) }
|
8
9
|
|
9
10
|
it 'stores the file' do
|
10
11
|
expect(subject.file).to eql(file)
|
@@ -15,7 +16,7 @@ RSpec.describe Licensee::Matchers::Exact do
|
|
15
16
|
end
|
16
17
|
|
17
18
|
it 'is confident' do
|
18
|
-
expect(subject.confidence).to
|
19
|
+
expect(subject.confidence).to be(100)
|
19
20
|
end
|
20
21
|
|
21
22
|
context 'with extra words added' do
|
@@ -1,19 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Licensee::Matchers::Gemspec do
|
4
|
+
subject { described_class.new(file) }
|
5
|
+
|
4
6
|
let(:mit) { Licensee::License.find('mit') }
|
5
7
|
let(:content) { "s.license = 'mit'" }
|
6
8
|
let(:file) do
|
7
9
|
Licensee::ProjectFiles::LicenseFile.new(content, 'project.gemspec')
|
8
10
|
end
|
9
|
-
subject { described_class.new(file) }
|
10
11
|
|
11
12
|
it 'matches' do
|
12
13
|
expect(subject.match).to eql(mit)
|
13
14
|
end
|
14
15
|
|
15
16
|
it 'has confidence' do
|
16
|
-
expect(subject.confidence).to
|
17
|
+
expect(subject.confidence).to be(90)
|
17
18
|
end
|
18
19
|
|
19
20
|
{
|
@@ -1,17 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Licensee::Matchers::Matcher do
|
4
|
+
subject { described_class.new(file) }
|
5
|
+
|
4
6
|
let(:mit) { Licensee::License.find('mit') }
|
5
7
|
let(:content) { sub_copyright_info(mit) }
|
6
8
|
let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.txt') }
|
7
|
-
subject { described_class.new(file) }
|
8
9
|
|
9
10
|
it 'stores the file' do
|
10
11
|
expect(subject.file).to eql(file)
|
11
12
|
end
|
12
13
|
|
13
14
|
it 'returns its name' do
|
14
|
-
expect(subject.name).to
|
15
|
+
expect(subject.name).to be(:matcher)
|
15
16
|
end
|
16
17
|
|
17
18
|
context 'to_h' do
|
@@ -22,6 +23,7 @@ RSpec.describe Licensee::Matchers::Matcher do
|
|
22
23
|
end
|
23
24
|
|
24
25
|
subject { MatcherSpecFixture.new(file) }
|
26
|
+
|
25
27
|
let(:hash) { subject.to_h }
|
26
28
|
let(:expected) do
|
27
29
|
{
|
@@ -1,19 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Licensee::Matchers::NpmBower do
|
4
|
+
subject { described_class.new(file) }
|
5
|
+
|
4
6
|
let(:content) { '"license": "mit"' }
|
5
7
|
let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.txt') }
|
6
8
|
let(:mit) { Licensee::License.find('mit') }
|
7
9
|
let(:other) { Licensee::License.find('other') }
|
8
10
|
|
9
|
-
subject { described_class.new(file) }
|
10
|
-
|
11
11
|
it 'matches' do
|
12
12
|
expect(subject.match).to eql(mit)
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'has a confidence' do
|
16
|
-
expect(subject.confidence).to
|
16
|
+
expect(subject.confidence).to be(90)
|
17
17
|
end
|
18
18
|
|
19
19
|
{
|
@@ -1,13 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Licensee::Matchers::Package do
|
4
|
+
subject { described_class.new(file) }
|
5
|
+
|
4
6
|
let(:mit) { Licensee::License.find('mit') }
|
5
7
|
let(:content) { '' }
|
6
8
|
let(:file) do
|
7
9
|
Licensee::ProjectFiles::LicenseFile.new(content, 'project.gemspec')
|
8
10
|
end
|
9
11
|
let(:license_property) { 'mit' }
|
10
|
-
|
12
|
+
|
11
13
|
before do
|
12
14
|
allow(subject).to receive(:license_property).and_return(license_property)
|
13
15
|
end
|
@@ -17,7 +19,7 @@ RSpec.describe Licensee::Matchers::Package do
|
|
17
19
|
end
|
18
20
|
|
19
21
|
it 'has confidence' do
|
20
|
-
expect(subject.confidence).to
|
22
|
+
expect(subject.confidence).to be(90)
|
21
23
|
end
|
22
24
|
|
23
25
|
context 'with a nil license property' do
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Licensee::Matchers::Reference do
|
4
|
+
subject { described_class.new(file) }
|
5
|
+
|
4
6
|
let(:content) { 'Copyright 2015 Ben Balter' }
|
5
7
|
let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.txt') }
|
6
8
|
let(:license) { Licensee::License.find('gpl-3.0') }
|
7
9
|
|
8
|
-
subject { described_class.new(file) }
|
9
|
-
|
10
10
|
%i[title key nickname].each do |variation|
|
11
11
|
context "with a license #{variation}" do
|
12
12
|
let(:content) { "Licensed under the #{license.send(variation)} license" }
|
@@ -1,20 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Licensee::Matchers::Spdx do
|
4
|
+
subject { described_class.new(file) }
|
5
|
+
|
4
6
|
let(:content) { 'PackageLicenseDeclared: MIT' }
|
5
7
|
let(:file) do
|
6
8
|
Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.spdx')
|
7
9
|
end
|
8
10
|
let(:mit) { Licensee::License.find('mit') }
|
9
11
|
let(:other) { Licensee::License.find('other') }
|
10
|
-
subject { described_class.new(file) }
|
11
12
|
|
12
13
|
it 'matches' do
|
13
14
|
expect(subject.match).to eql(mit)
|
14
15
|
end
|
15
16
|
|
16
17
|
it 'has a confidence' do
|
17
|
-
expect(subject.confidence).to
|
18
|
+
expect(subject.confidence).to be(90)
|
18
19
|
end
|
19
20
|
|
20
21
|
context 'no license field' do
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Licensee::ProjectFiles::LicenseFile do
|
4
|
+
subject { described_class.new(content, filename) }
|
5
|
+
|
4
6
|
let(:filename) { 'LICENSE.txt' }
|
5
7
|
let(:gpl) { Licensee::License.find('gpl-3.0') }
|
6
8
|
let(:mit) { Licensee::License.find('mit') }
|
7
9
|
let(:content) { sub_copyright_info(mit) }
|
8
10
|
let(:content_hash) { license_hashes['mit'] }
|
9
11
|
|
10
|
-
subject { described_class.new(content, filename) }
|
11
|
-
|
12
12
|
it 'parses the attribution' do
|
13
13
|
expect(subject.attribution).to eql('Copyright (c) 2018 Ben Balter')
|
14
14
|
end
|
@@ -47,7 +47,7 @@ RSpec.describe Licensee::ProjectFiles::LicenseFile do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'creates the wordset' do
|
50
|
-
expect(subject.wordset.count).to
|
50
|
+
expect(subject.wordset.count).to be(91)
|
51
51
|
expect(subject.wordset.first).to eql('permission')
|
52
52
|
end
|
53
53
|
|
@@ -119,11 +119,11 @@ RSpec.describe Licensee::ProjectFiles::LicenseFile do
|
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'does not match .md2' do
|
122
|
-
expect(described_class::PREFERRED_EXT_REGEX).
|
122
|
+
expect(described_class::PREFERRED_EXT_REGEX).not_to match('.md2')
|
123
123
|
end
|
124
124
|
|
125
125
|
it 'does not match .md/foo' do
|
126
|
-
expect(described_class::PREFERRED_EXT_REGEX).
|
126
|
+
expect(described_class::PREFERRED_EXT_REGEX).not_to match('.md/foo')
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
@@ -133,7 +133,7 @@ RSpec.describe Licensee::ProjectFiles::LicenseFile do
|
|
133
133
|
end
|
134
134
|
|
135
135
|
it 'does not match .md/foo' do
|
136
|
-
expect(described_class::OTHER_EXT_REGEX).
|
136
|
+
expect(described_class::OTHER_EXT_REGEX).not_to match('.md/foo')
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
@@ -158,8 +158,8 @@ RSpec.describe Licensee::ProjectFiles::LicenseFile do
|
|
158
158
|
let(:regex) { Licensee::ProjectFiles::LicenseFile::CC_FALSE_POSITIVE_REGEX }
|
159
159
|
|
160
160
|
it "knows MIT isn't a potential false positive" do
|
161
|
-
expect(subject.content).
|
162
|
-
expect(subject).
|
161
|
+
expect(subject.content).not_to match(regex)
|
162
|
+
expect(subject).not_to be_a_potential_false_positive
|
163
163
|
end
|
164
164
|
|
165
165
|
context 'a CC false positive without creative commons in the title' do
|
@@ -191,10 +191,10 @@ RSpec.describe Licensee::ProjectFiles::LicenseFile do
|
|
191
191
|
|
192
192
|
context 'CC-BY-ND with leading instructions' do
|
193
193
|
let(:content) do
|
194
|
-
|
195
|
-
Creative Commons Corporation ("Creative Commons") is not a law firm
|
196
|
-
======================================================================
|
197
|
-
Creative Commons Attribution-NonCommercial 4.0
|
194
|
+
<<~LICENSE
|
195
|
+
Creative Commons Corporation ("Creative Commons") is not a law firm
|
196
|
+
======================================================================
|
197
|
+
Creative Commons Attribution-NonCommercial 4.0
|
198
198
|
LICENSE
|
199
199
|
end
|
200
200
|
|
@@ -220,7 +220,7 @@ Creative Commons Attribution-NonCommercial 4.0
|
|
220
220
|
let(:content) { sub_copyright_info(mit) }
|
221
221
|
|
222
222
|
it 'is not lgpl' do
|
223
|
-
expect(subject).
|
223
|
+
expect(subject).not_to be_lgpl
|
224
224
|
end
|
225
225
|
end
|
226
226
|
end
|
@@ -229,7 +229,7 @@ Creative Commons Attribution-NonCommercial 4.0
|
|
229
229
|
let(:filename) { 'COPYING' }
|
230
230
|
|
231
231
|
it 'is not lgpl' do
|
232
|
-
expect(subject).
|
232
|
+
expect(subject).not_to be_lgpl
|
233
233
|
end
|
234
234
|
end
|
235
235
|
end
|
@@ -245,7 +245,7 @@ Creative Commons Attribution-NonCommercial 4.0
|
|
245
245
|
let(:content) { sub_copyright_info(mit) }
|
246
246
|
|
247
247
|
it 'is not GPL' do
|
248
|
-
expect(subject).
|
248
|
+
expect(subject).not_to be_gpl
|
249
249
|
end
|
250
250
|
end
|
251
251
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Licensee::ProjectFiles::PackageManagerFile do
|
4
|
+
subject { described_class.new(content, filename) }
|
5
|
+
|
4
6
|
let(:content) { '' }
|
5
7
|
let(:filename) { '' }
|
6
|
-
subject { described_class.new(content, filename) }
|
7
8
|
|
8
9
|
context 'name scoring' do
|
9
10
|
{
|
@@ -19,6 +20,7 @@ RSpec.describe Licensee::ProjectFiles::PackageManagerFile do
|
|
19
20
|
}.each do |filename, expected_score|
|
20
21
|
context "a file named #{filename}" do
|
21
22
|
let(:score) { described_class.name_score(filename) }
|
23
|
+
|
22
24
|
it 'scores the file' do
|
23
25
|
expect(score).to eql(expected_score)
|
24
26
|
end
|
@@ -1,16 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Licensee::ProjectFiles::ProjectFile do
|
4
|
+
subject { Licensee::ProjectFiles::LicenseFile.new(content, filename) }
|
5
|
+
|
4
6
|
let(:filename) { 'LICENSE.txt' }
|
5
7
|
let(:mit) { Licensee::License.find('mit') }
|
6
8
|
let(:content) { mit.content }
|
7
9
|
let(:possible_matchers) { [Licensee::Matchers::Exact] }
|
8
10
|
|
9
|
-
subject { Licensee::ProjectFiles::LicenseFile.new(content, filename) }
|
10
11
|
before do
|
11
12
|
allow(subject).to receive(:possible_matchers).and_return(possible_matchers)
|
12
13
|
end
|
14
|
+
|
13
15
|
before { allow(subject).to receive(:length).and_return(mit.length) }
|
16
|
+
|
14
17
|
before { allow(subject).to receive(:wordset).and_return(mit.wordset) }
|
15
18
|
|
16
19
|
it 'stores the content' do
|
@@ -26,7 +29,7 @@ RSpec.describe Licensee::ProjectFiles::ProjectFile do
|
|
26
29
|
end
|
27
30
|
|
28
31
|
it 'returns the confidence' do
|
29
|
-
expect(subject.confidence).to
|
32
|
+
expect(subject.confidence).to be(100)
|
30
33
|
end
|
31
34
|
|
32
35
|
it 'returns the license' do
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Licensee::ProjectFiles::ReadmeFile do
|
4
|
+
subject { described_class.new(content, filename) }
|
5
|
+
|
4
6
|
let(:filename) { 'README.md' }
|
5
7
|
let(:content) { '' }
|
6
|
-
subject { described_class.new(content, filename) }
|
7
8
|
|
8
9
|
context 'scoring names' do
|
9
10
|
{
|
@@ -6,13 +6,14 @@
|
|
6
6
|
Licensee::Projects::GitHubProject
|
7
7
|
].each do |project_type|
|
8
8
|
RSpec.describe project_type do
|
9
|
+
subject { described_class.new(path) }
|
10
|
+
|
9
11
|
let(:stubbed_org) { '_licensee_test_fixture' }
|
10
12
|
let(:mit) { Licensee::License.find('mit') }
|
11
13
|
let(:other) { Licensee::License.find('other') }
|
12
14
|
let(:fixture) { 'mit' }
|
13
15
|
let(:path) { fixture_path(fixture) }
|
14
16
|
let(:api_base) { 'https://api.github.com/repos' }
|
15
|
-
subject { described_class.new(path) }
|
16
17
|
|
17
18
|
if described_class == Licensee::Projects::GitProject
|
18
19
|
before do
|
@@ -46,14 +47,16 @@
|
|
46
47
|
.to_return(status: 200, body: File.read(file))
|
47
48
|
end
|
48
49
|
end
|
50
|
+
|
49
51
|
let(:path) { "https://github.com/#{stubbed_org}/#{fixture}" }
|
50
52
|
end
|
51
53
|
|
52
54
|
if described_class == Licensee::Projects::GitProject
|
53
55
|
context 'when initialized with a repo' do
|
54
|
-
let(:repo) { Rugged::Repository.new(path) }
|
55
56
|
subject { described_class.new(repo) }
|
56
57
|
|
58
|
+
let(:repo) { Rugged::Repository.new(path) }
|
59
|
+
|
57
60
|
it 'returns the repository' do
|
58
61
|
expect(subject.repository).to be_a(Rugged::Repository)
|
59
62
|
end
|
@@ -61,6 +64,7 @@
|
|
61
64
|
|
62
65
|
context 'when initialized with a revision' do
|
63
66
|
let(:revision) { subject.repository.last_commit.oid }
|
67
|
+
|
64
68
|
before do
|
65
69
|
subject.instance_variable_set('@revision', revision)
|
66
70
|
end
|
@@ -98,9 +102,9 @@
|
|
98
102
|
let(:files) { subject.send(:files) }
|
99
103
|
|
100
104
|
it 'returns the file list' do
|
101
|
-
expect(files.count).to
|
105
|
+
expect(files.count).to be(2)
|
102
106
|
license = files.find { |f| f[:name] == 'LICENSE.txt' }
|
103
|
-
expect(license).
|
107
|
+
expect(license).not_to be_nil
|
104
108
|
|
105
109
|
if described_class == Licensee::Projects::GitProject
|
106
110
|
expect(files.first).to have_key(:oid)
|
@@ -123,7 +127,7 @@
|
|
123
127
|
|
124
128
|
it 'looks for licenses in parent directories up to the search root' do
|
125
129
|
# should not include the license in 'license-in-parent-folder' dir
|
126
|
-
expect(files.count).to
|
130
|
+
expect(files.count).to be(1)
|
127
131
|
expect(files.first[:name]).to eql('LICENSE.txt')
|
128
132
|
end
|
129
133
|
end
|
@@ -132,7 +136,7 @@
|
|
132
136
|
let(:fixture) { 'license-in-parent-folder/license-folder/package' }
|
133
137
|
|
134
138
|
it 'looks for licenses in current directory only' do
|
135
|
-
expect(files.count).to
|
139
|
+
expect(files.count).to be(0)
|
136
140
|
end
|
137
141
|
end
|
138
142
|
end
|
@@ -149,9 +153,10 @@
|
|
149
153
|
end
|
150
154
|
|
151
155
|
context 'readme detection' do
|
152
|
-
let(:fixture) { 'readme' }
|
153
156
|
subject { described_class.new(path, detect_readme: true) }
|
154
157
|
|
158
|
+
let(:fixture) { 'readme' }
|
159
|
+
|
155
160
|
it 'returns the readme' do
|
156
161
|
expect(subject.readme_file).to be_a(Licensee::ProjectFiles::ReadmeFile)
|
157
162
|
expect(subject.readme_file.filename).to eql('README.md')
|
@@ -164,6 +169,8 @@
|
|
164
169
|
end
|
165
170
|
|
166
171
|
context 'package manager detection' do
|
172
|
+
subject { described_class.new(path, detect_packages: true) }
|
173
|
+
|
167
174
|
let(:fixture) { 'gemspec' }
|
168
175
|
|
169
176
|
# Using a `.gemspec` extension in the fixture breaks `gem release`
|
@@ -202,8 +209,6 @@
|
|
202
209
|
FileUtils.rm("#{fixture_path(fixture)}/project.gemspec")
|
203
210
|
end
|
204
211
|
|
205
|
-
subject { described_class.new(path, detect_packages: true) }
|
206
|
-
|
207
212
|
it 'returns the package file' do
|
208
213
|
expected = Licensee::ProjectFiles::PackageManagerFile
|
209
214
|
expect(subject.package_file).to be_a(expected)
|
@@ -232,19 +237,19 @@
|
|
232
237
|
end
|
233
238
|
|
234
239
|
it 'returns both licenses' do
|
235
|
-
expect(subject.licenses.count).to
|
240
|
+
expect(subject.licenses.count).to be(2)
|
236
241
|
expect(subject.licenses.first).to eql(Licensee::License.find('mpl-2.0'))
|
237
242
|
expect(subject.licenses.last).to eql(mit)
|
238
243
|
end
|
239
244
|
|
240
245
|
it 'returns both matched_files' do
|
241
|
-
expect(subject.matched_files.count).to
|
246
|
+
expect(subject.matched_files.count).to be(2)
|
242
247
|
expect(subject.matched_files.first.filename).to eql('LICENSE')
|
243
248
|
expect(subject.matched_files.last.filename).to eql('LICENSE.txt')
|
244
249
|
end
|
245
250
|
|
246
251
|
it 'returns both license_files' do
|
247
|
-
expect(subject.license_files.count).to
|
252
|
+
expect(subject.license_files.count).to be(2)
|
248
253
|
expect(subject.license_files.first.filename).to eql('LICENSE')
|
249
254
|
expect(subject.license_files.last.filename).to eql('LICENSE.txt')
|
250
255
|
end
|
@@ -260,29 +265,29 @@
|
|
260
265
|
end
|
261
266
|
|
262
267
|
it 'matched_file returns copying.lesser' do
|
263
|
-
expect(subject.matched_file).
|
268
|
+
expect(subject.matched_file).not_to be_nil
|
264
269
|
expect(subject.matched_file.filename).to eql('COPYING.lesser')
|
265
270
|
end
|
266
271
|
|
267
272
|
it 'license_file returns copying.lesser' do
|
268
|
-
expect(subject.license_file).
|
273
|
+
expect(subject.license_file).not_to be_nil
|
269
274
|
expect(subject.license_file.filename).to eql('COPYING.lesser')
|
270
275
|
end
|
271
276
|
|
272
277
|
it 'returns both licenses' do
|
273
|
-
expect(subject.licenses.count).to
|
278
|
+
expect(subject.licenses.count).to be(2)
|
274
279
|
expect(subject.licenses.first).to eql(lgpl)
|
275
280
|
expect(subject.licenses.last).to eql(gpl)
|
276
281
|
end
|
277
282
|
|
278
283
|
it 'returns both matched_files' do
|
279
|
-
expect(subject.matched_files.count).to
|
284
|
+
expect(subject.matched_files.count).to be(2)
|
280
285
|
expect(subject.matched_files.first.filename).to eql('COPYING.lesser')
|
281
286
|
expect(subject.matched_files.last.filename).to eql('LICENSE')
|
282
287
|
end
|
283
288
|
|
284
289
|
it 'returns both license_files' do
|
285
|
-
expect(subject.license_files.count).to
|
290
|
+
expect(subject.license_files.count).to be(2)
|
286
291
|
expect(subject.license_files.first.filename).to eql('COPYING.lesser')
|
287
292
|
expect(subject.license_files.last.filename).to eql('LICENSE')
|
288
293
|
end
|