licensee 9.12.0 → 9.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.md +1 -1
- data/bin/licensee +4 -4
- data/lib/licensee.rb +3 -3
- data/lib/licensee/commands/detect.rb +6 -6
- data/lib/licensee/commands/diff.rb +2 -2
- data/lib/licensee/content_helper.rb +72 -26
- data/lib/licensee/hash_helper.rb +5 -5
- data/lib/licensee/license.rb +17 -21
- data/lib/licensee/matchers.rb +1 -0
- data/lib/licensee/matchers/cabal.rb +1 -1
- data/lib/licensee/matchers/cargo.rb +1 -1
- data/lib/licensee/matchers/copyright.rb +3 -3
- data/lib/licensee/matchers/dice.rb +4 -4
- data/lib/licensee/matchers/dist_zilla.rb +1 -1
- data/lib/licensee/matchers/gemspec.rb +4 -4
- data/lib/licensee/matchers/npm_bower.rb +5 -2
- data/lib/licensee/matchers/nuget.rb +43 -0
- data/lib/licensee/matchers/spdx.rb +1 -1
- data/lib/licensee/project_files/license_file.rb +3 -3
- data/lib/licensee/project_files/package_manager_file.rb +3 -2
- data/lib/licensee/project_files/project_file.rb +2 -1
- data/lib/licensee/projects/fs_project.rb +7 -2
- data/lib/licensee/projects/git_project.rb +3 -3
- data/lib/licensee/projects/github_project.rb +1 -1
- data/lib/licensee/projects/project.rb +3 -3
- data/lib/licensee/version.rb +1 -1
- data/licensee.gemspec +45 -0
- data/spec/bin_spec.rb +1 -1
- data/spec/fixture_spec.rb +5 -5
- data/spec/fixtures/bom/LICENSE.txt +21 -0
- data/spec/fixtures/bsd-3-noendorseslash/LICENSE +30 -0
- data/spec/fixtures/cc0-cal2013/LICENSE +116 -0
- data/spec/fixtures/cc0-cc/LICENSE +121 -0
- data/spec/fixtures/crlf-bsd/LICENSE.md +27 -0
- data/spec/fixtures/detect.json +14 -20
- data/spec/fixtures/fixtures.yml +43 -3
- data/spec/fixtures/license-hashes.json +10 -8
- data/spec/fixtures/markdown-artistic/LICENSE.md +192 -0
- data/spec/fixtures/multiple-arrs/LICENSE +30 -0
- data/spec/fixtures/readme-invalid-encoding/README.md +24 -0
- data/spec/fixtures/unlicense-noinfo/LICENSE +22 -0
- data/spec/fixtures/vim/LICENSE +78 -0
- data/spec/integration_spec.rb +87 -4
- data/spec/licensee/commands/detect_spec.rb +5 -5
- 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 +46 -50
- data/spec/licensee/hash_helper_spec.rb +23 -23
- data/spec/licensee/license_field_spec.rb +3 -3
- data/spec/licensee/license_meta_spec.rb +18 -22
- data/spec/licensee/license_rules_spec.rb +4 -2
- data/spec/licensee/license_spec.rb +43 -39
- 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 +15 -21
- 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 +10 -8
- data/spec/licensee/matchers/npm_bower_matcher_spec.rb +12 -3
- data/spec/licensee/matchers/nu_get_matcher_spec.rb +91 -0
- 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 +43 -42
- data/spec/licensee/project_files/package_info_spec.rb +11 -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 +5 -4
- data/spec/licensee_spec.rb +10 -9
- data/spec/spec_helper.rb +2 -2
- data/spec/vendored_license_spec.rb +5 -5
- data/vendor/choosealicense.com/_data/meta.yml +1 -1
- data/vendor/choosealicense.com/_data/rules.yml +15 -12
- data/vendor/choosealicense.com/_licenses/0bsd.txt +3 -3
- data/vendor/choosealicense.com/_licenses/apache-2.0.txt +4 -4
- data/vendor/choosealicense.com/_licenses/artistic-2.0.txt +1 -1
- data/vendor/choosealicense.com/_licenses/bsd-2-clause.txt +3 -3
- data/vendor/choosealicense.com/_licenses/bsd-3-clause-clear.txt +1 -0
- data/vendor/choosealicense.com/_licenses/bsd-3-clause.txt +3 -3
- data/vendor/choosealicense.com/_licenses/bsd-4-clause.txt +61 -0
- data/vendor/choosealicense.com/_licenses/bsl-1.0.txt +5 -1
- data/vendor/choosealicense.com/_licenses/cc-by-4.0.txt +16 -13
- data/vendor/choosealicense.com/_licenses/cc-by-sa-4.0.txt +16 -13
- data/vendor/choosealicense.com/_licenses/cc0-1.0.txt +113 -104
- data/vendor/choosealicense.com/_licenses/cecill-2.1.txt +6 -6
- data/vendor/choosealicense.com/_licenses/ecl-2.0.txt +4 -4
- data/vendor/choosealicense.com/_licenses/epl-1.0.txt +3 -3
- data/vendor/choosealicense.com/_licenses/epl-2.0.txt +5 -5
- data/vendor/choosealicense.com/_licenses/eupl-1.2.txt +3 -3
- data/vendor/choosealicense.com/_licenses/gpl-2.0.txt +3 -3
- data/vendor/choosealicense.com/_licenses/gpl-3.0.txt +4 -4
- data/vendor/choosealicense.com/_licenses/isc.txt +3 -3
- data/vendor/choosealicense.com/_licenses/lgpl-3.0.txt +0 -1
- data/vendor/choosealicense.com/_licenses/lppl-1.3c.txt +1 -1
- data/vendor/choosealicense.com/_licenses/mit.txt +3 -3
- data/vendor/choosealicense.com/_licenses/mpl-2.0.txt +3 -3
- data/vendor/choosealicense.com/_licenses/ncsa.txt +24 -24
- data/vendor/choosealicense.com/_licenses/odbl-1.0.txt +3 -3
- data/vendor/choosealicense.com/_licenses/ofl-1.1.txt +4 -1
- data/vendor/choosealicense.com/_licenses/osl-3.0.txt +3 -3
- data/vendor/choosealicense.com/_licenses/postgresql.txt +5 -5
- data/vendor/choosealicense.com/_licenses/unlicense.txt +3 -3
- data/vendor/choosealicense.com/_licenses/upl-1.0.txt +4 -4
- data/vendor/choosealicense.com/_licenses/vim.txt +111 -0
- data/vendor/choosealicense.com/_licenses/zlib.txt +4 -1
- metadata +62 -21
@@ -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(92)
|
51
51
|
expect(subject.wordset.first).to eql('permission')
|
52
52
|
end
|
53
53
|
|
@@ -57,32 +57,33 @@ RSpec.describe Licensee::ProjectFiles::LicenseFile do
|
|
57
57
|
|
58
58
|
context 'filename scoring' do
|
59
59
|
{
|
60
|
-
'license'
|
61
|
-
'LICENCE'
|
62
|
-
'unLICENSE'
|
63
|
-
'unlicence'
|
64
|
-
'license.md'
|
65
|
-
'LICENSE.md'
|
66
|
-
'license.txt'
|
67
|
-
'COPYING'
|
68
|
-
'copyRIGHT'
|
69
|
-
'COPYRIGHT.txt'
|
70
|
-
'copying.txt'
|
71
|
-
'LICENSE.php'
|
72
|
-
'LICENCE.docs'
|
73
|
-
'copying.image'
|
74
|
-
'COPYRIGHT.go'
|
75
|
-
'LICENSE-MIT'
|
76
|
-
'LICENSE_1_0.txt'
|
77
|
-
'COPYING-GPL'
|
78
|
-
'COPYRIGHT-BSD'
|
79
|
-
'MIT-LICENSE.txt'
|
80
|
-
'mit-license-foo.md'
|
81
|
-
'OFL.md'
|
82
|
-
'ofl.textile'
|
83
|
-
'ofl'
|
84
|
-
'not-the-ofl'
|
85
|
-
'README.txt'
|
60
|
+
'license' => 1.00,
|
61
|
+
'LICENCE' => 1.00,
|
62
|
+
'unLICENSE' => 1.00,
|
63
|
+
'unlicence' => 1.00,
|
64
|
+
'license.md' => 0.95,
|
65
|
+
'LICENSE.md' => 0.95,
|
66
|
+
'license.txt' => 0.95,
|
67
|
+
'COPYING' => 0.90,
|
68
|
+
'copyRIGHT' => 0.90,
|
69
|
+
'COPYRIGHT.txt' => 0.85,
|
70
|
+
'copying.txt' => 0.85,
|
71
|
+
'LICENSE.php' => 0.80,
|
72
|
+
'LICENCE.docs' => 0.80,
|
73
|
+
'copying.image' => 0.75,
|
74
|
+
'COPYRIGHT.go' => 0.75,
|
75
|
+
'LICENSE-MIT' => 0.70,
|
76
|
+
'LICENSE_1_0.txt' => 0.70,
|
77
|
+
'COPYING-GPL' => 0.65,
|
78
|
+
'COPYRIGHT-BSD' => 0.65,
|
79
|
+
'MIT-LICENSE.txt' => 0.60,
|
80
|
+
'mit-license-foo.md' => 0.60,
|
81
|
+
'OFL.md' => 0.50,
|
82
|
+
'ofl.textile' => 0.45,
|
83
|
+
'ofl' => 0.40,
|
84
|
+
'not-the-ofl' => 0.00,
|
85
|
+
'README.txt' => 0.00,
|
86
|
+
'.pip-license-ignore' => 0.00
|
86
87
|
}.each do |filename, expected|
|
87
88
|
context "a file named #{filename}" do
|
88
89
|
let(:score) { described_class.name_score(filename) }
|
@@ -119,11 +120,11 @@ RSpec.describe Licensee::ProjectFiles::LicenseFile do
|
|
119
120
|
end
|
120
121
|
|
121
122
|
it 'does not match .md2' do
|
122
|
-
expect(described_class::PREFERRED_EXT_REGEX).
|
123
|
+
expect(described_class::PREFERRED_EXT_REGEX).not_to match('.md2')
|
123
124
|
end
|
124
125
|
|
125
126
|
it 'does not match .md/foo' do
|
126
|
-
expect(described_class::PREFERRED_EXT_REGEX).
|
127
|
+
expect(described_class::PREFERRED_EXT_REGEX).not_to match('.md/foo')
|
127
128
|
end
|
128
129
|
end
|
129
130
|
|
@@ -133,7 +134,7 @@ RSpec.describe Licensee::ProjectFiles::LicenseFile do
|
|
133
134
|
end
|
134
135
|
|
135
136
|
it 'does not match .md/foo' do
|
136
|
-
expect(described_class::OTHER_EXT_REGEX).
|
137
|
+
expect(described_class::OTHER_EXT_REGEX).not_to match('.md/foo')
|
137
138
|
end
|
138
139
|
end
|
139
140
|
|
@@ -158,11 +159,11 @@ RSpec.describe Licensee::ProjectFiles::LicenseFile do
|
|
158
159
|
let(:regex) { Licensee::ProjectFiles::LicenseFile::CC_FALSE_POSITIVE_REGEX }
|
159
160
|
|
160
161
|
it "knows MIT isn't a potential false positive" do
|
161
|
-
expect(subject.content).
|
162
|
-
expect(subject).
|
162
|
+
expect(subject.content).not_to match(regex)
|
163
|
+
expect(subject).not_to be_a_potential_false_positive
|
163
164
|
end
|
164
165
|
|
165
|
-
context 'a CC false positive
|
166
|
+
context 'a CC false positive with creative commons in the title' do
|
166
167
|
let(:content) { 'Creative Commons Attribution-NonCommercial 4.0' }
|
167
168
|
|
168
169
|
it "knows it's a potential false positive" do
|
@@ -191,10 +192,10 @@ RSpec.describe Licensee::ProjectFiles::LicenseFile do
|
|
191
192
|
|
192
193
|
context 'CC-BY-ND with leading instructions' do
|
193
194
|
let(:content) do
|
194
|
-
|
195
|
-
Creative Commons Corporation ("Creative Commons") is not a law firm
|
196
|
-
======================================================================
|
197
|
-
Creative Commons Attribution-NonCommercial 4.0
|
195
|
+
<<~LICENSE
|
196
|
+
Creative Commons Corporation ("Creative Commons") is not a law firm
|
197
|
+
======================================================================
|
198
|
+
Creative Commons Attribution-NonCommercial 4.0
|
198
199
|
LICENSE
|
199
200
|
end
|
200
201
|
|
@@ -220,7 +221,7 @@ Creative Commons Attribution-NonCommercial 4.0
|
|
220
221
|
let(:content) { sub_copyright_info(mit) }
|
221
222
|
|
222
223
|
it 'is not lgpl' do
|
223
|
-
expect(subject).
|
224
|
+
expect(subject).not_to be_lgpl
|
224
225
|
end
|
225
226
|
end
|
226
227
|
end
|
@@ -229,7 +230,7 @@ Creative Commons Attribution-NonCommercial 4.0
|
|
229
230
|
let(:filename) { 'COPYING' }
|
230
231
|
|
231
232
|
it 'is not lgpl' do
|
232
|
-
expect(subject).
|
233
|
+
expect(subject).not_to be_lgpl
|
233
234
|
end
|
234
235
|
end
|
235
236
|
end
|
@@ -245,7 +246,7 @@ Creative Commons Attribution-NonCommercial 4.0
|
|
245
246
|
let(:content) { sub_copyright_info(mit) }
|
246
247
|
|
247
248
|
it 'is not GPL' do
|
248
|
-
expect(subject).
|
249
|
+
expect(subject).not_to be_gpl
|
249
250
|
end
|
250
251
|
end
|
251
252
|
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
|
@@ -69,5 +71,13 @@ RSpec.describe Licensee::ProjectFiles::PackageManagerFile do
|
|
69
71
|
expect(possible_matchers).to eql([Licensee::Matchers::Cran])
|
70
72
|
end
|
71
73
|
end
|
74
|
+
|
75
|
+
context 'with nuspec file' do
|
76
|
+
let(:filename) { 'foo.nuspec' }
|
77
|
+
|
78
|
+
it 'returns the NuGet matcher' do
|
79
|
+
expect(possible_matchers).to eql([Licensee::Matchers::NuGet])
|
80
|
+
end
|
81
|
+
end
|
72
82
|
end
|
73
83
|
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
|
@@ -1,16 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Licensee::Projects::GitHubProject do
|
4
|
+
subject(:instance) { described_class.new(github_url) }
|
5
|
+
|
4
6
|
let(:repo) { 'benbalter/licensee' }
|
5
7
|
let(:github_url) { "https://github.com/#{repo}" }
|
6
8
|
let(:mit) { Licensee::License.find('mit') }
|
7
9
|
let(:readme_file) { File.read(fixture_path('mit/README.md')) }
|
8
10
|
let(:license_file) { File.read(fixture_path('mit/LICENSE.txt')) }
|
9
|
-
subject(:instance) { described_class.new(github_url) }
|
10
11
|
|
11
12
|
describe '#initialize' do
|
12
13
|
context 'with a GitHub URI' do
|
13
|
-
it '
|
14
|
+
it 'sets @repo' do
|
14
15
|
expect(instance.repo).to eq(repo)
|
15
16
|
end
|
16
17
|
end
|
@@ -18,7 +19,7 @@ RSpec.describe Licensee::Projects::GitHubProject do
|
|
18
19
|
context 'with a GitHub git URI' do
|
19
20
|
let(:github_url) { "https://github.com/#{repo}.git" }
|
20
21
|
|
21
|
-
it '
|
22
|
+
it 'sets @repo, stripping the trailing extension' do
|
22
23
|
expect(instance.repo).to eq(repo)
|
23
24
|
end
|
24
25
|
end
|
@@ -26,7 +27,7 @@ RSpec.describe Licensee::Projects::GitHubProject do
|
|
26
27
|
context 'with a non-GitHub URI' do
|
27
28
|
let(:github_url) { "https://gitlab.com/#{repo}" }
|
28
29
|
|
29
|
-
it '
|
30
|
+
it 'raises an ArgumentError' do
|
30
31
|
expect { instance }.to raise_error(ArgumentError)
|
31
32
|
end
|
32
33
|
end
|
@@ -34,7 +35,7 @@ RSpec.describe Licensee::Projects::GitHubProject do
|
|
34
35
|
context 'with a local folder' do
|
35
36
|
let(:github_url) { fixture_path('mit') }
|
36
37
|
|
37
|
-
it '
|
38
|
+
it 'raises an ArgumentError' do
|
38
39
|
expect { instance }.to raise_error(ArgumentError)
|
39
40
|
end
|
40
41
|
end
|