licensee 9.10.0 → 9.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/licensee +5 -4
- data/lib/licensee.rb +4 -2
- data/lib/licensee/commands/detect.rb +10 -5
- data/lib/licensee/commands/diff.rb +7 -8
- data/lib/licensee/commands/license_path.rb +2 -0
- data/lib/licensee/commands/version.rb +2 -0
- data/lib/licensee/content_helper.rb +234 -85
- data/lib/licensee/hash_helper.rb +7 -5
- data/lib/licensee/license.rb +32 -25
- data/lib/licensee/license_field.rb +4 -1
- data/lib/licensee/license_meta.rb +3 -0
- data/lib/licensee/license_rules.rb +2 -0
- data/lib/licensee/matchers.rb +2 -0
- data/lib/licensee/matchers/cabal.rb +16 -2
- data/lib/licensee/matchers/cargo.rb +3 -1
- data/lib/licensee/matchers/copyright.rb +6 -4
- data/lib/licensee/matchers/cran.rb +7 -3
- data/lib/licensee/matchers/dice.rb +6 -4
- data/lib/licensee/matchers/dist_zilla.rb +3 -1
- data/lib/licensee/matchers/exact.rb +3 -0
- data/lib/licensee/matchers/gemspec.rb +8 -5
- data/lib/licensee/matchers/matcher.rb +3 -1
- data/lib/licensee/matchers/npm_bower.rb +3 -1
- data/lib/licensee/matchers/package.rb +3 -0
- data/lib/licensee/matchers/reference.rb +3 -1
- data/lib/licensee/matchers/spdx.rb +3 -1
- data/lib/licensee/project_files.rb +2 -0
- data/lib/licensee/project_files/license_file.rb +13 -10
- data/lib/licensee/project_files/package_manager_file.rb +3 -0
- data/lib/licensee/project_files/project_file.rb +12 -4
- data/lib/licensee/project_files/readme_file.rb +5 -3
- data/lib/licensee/projects.rb +2 -0
- data/lib/licensee/projects/fs_project.rb +3 -0
- data/lib/licensee/projects/git_project.rb +19 -11
- data/lib/licensee/projects/github_project.rb +6 -1
- data/lib/licensee/projects/project.rb +16 -5
- data/lib/licensee/rule.rb +2 -0
- data/lib/licensee/version.rb +3 -1
- data/licensee.gemspec +47 -0
- data/spec/bin_spec.rb +3 -1
- data/spec/fixture_spec.rb +46 -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/detect.json +9 -7
- data/spec/fixtures/fixtures.yml +130 -0
- data/spec/fixtures/html/license.html +262 -0
- data/spec/fixtures/license-hashes.json +41 -0
- data/spec/fixtures/mit-optional/LICENSE.txt +21 -0
- data/spec/fixtures/multiple-arrs/LICENSE +30 -0
- data/spec/fixtures/unlicense-noinfo/LICENSE +22 -0
- data/spec/integration_spec.rb +68 -2
- data/spec/licensee/commands/detect_spec.rb +10 -6
- data/spec/licensee/commands/license_path_spec.rb +3 -1
- data/spec/licensee/commands/version_spec.rb +3 -1
- data/spec/licensee/content_helper_spec.rb +184 -67
- data/spec/licensee/hash_helper_spec.rb +3 -1
- data/spec/licensee/license_field_spec.rb +5 -3
- data/spec/licensee/license_meta_spec.rb +16 -12
- data/spec/licensee/license_rules_spec.rb +6 -2
- data/spec/licensee/license_spec.rb +62 -37
- data/spec/licensee/matchers/cabal_matcher_spec.rb +97 -2
- data/spec/licensee/matchers/cargo_matcher_spec.rb +5 -2
- data/spec/licensee/matchers/copyright_matcher_spec.rb +7 -5
- data/spec/licensee/matchers/cran_matcher_spec.rb +5 -2
- data/spec/licensee/matchers/dice_matcher_spec.rb +15 -12
- data/spec/licensee/matchers/dist_zilla_matcher_spec.rb +5 -2
- data/spec/licensee/matchers/exact_matcher_spec.rb +5 -2
- data/spec/licensee/matchers/gemspec_matcher_spec.rb +5 -2
- data/spec/licensee/matchers/matcher_spec.rb +6 -2
- data/spec/licensee/matchers/npm_bower_matcher_spec.rb +5 -3
- data/spec/licensee/matchers/package_matcher_spec.rb +6 -2
- data/spec/licensee/matchers/reference_matcher_spec.rb +4 -2
- data/spec/licensee/matchers/spdx_matcher_spec.rb +5 -2
- data/spec/licensee/project_files/license_file_spec.rb +20 -18
- data/spec/licensee/project_files/package_info_spec.rb +5 -1
- data/spec/licensee/project_files/project_file_spec.rb +8 -2
- data/spec/licensee/project_files/readme_file_spec.rb +4 -1
- data/spec/licensee/project_spec.rb +24 -17
- data/spec/licensee/projects/git_project_spec.rb +23 -0
- data/spec/licensee/projects/github_project_spec.rb +8 -5
- data/spec/licensee/rule_spec.rb +6 -3
- data/spec/licensee_spec.rb +12 -9
- data/spec/spec_helper.rb +28 -9
- data/spec/vendored_license_spec.rb +29 -10
- data/vendor/choosealicense.com/_data/meta.yml +0 -4
- data/vendor/choosealicense.com/_data/rules.yml +3 -0
- data/vendor/choosealicense.com/_licenses/0bsd.txt +39 -0
- data/vendor/choosealicense.com/_licenses/afl-3.0.txt +7 -6
- data/vendor/choosealicense.com/_licenses/agpl-3.0.txt +0 -1
- data/vendor/choosealicense.com/_licenses/apache-2.0.txt +1 -2
- data/vendor/choosealicense.com/_licenses/artistic-2.0.txt +1 -2
- data/vendor/choosealicense.com/_licenses/bsd-2-clause.txt +8 -6
- data/vendor/choosealicense.com/_licenses/bsd-3-clause-clear.txt +2 -2
- data/vendor/choosealicense.com/_licenses/bsd-3-clause.txt +12 -10
- data/vendor/choosealicense.com/_licenses/bsd-4-clause.txt +61 -0
- data/vendor/choosealicense.com/_licenses/bsl-1.0.txt +5 -2
- data/vendor/choosealicense.com/_licenses/cc-by-4.0.txt +3 -1
- data/vendor/choosealicense.com/_licenses/cc-by-sa-4.0.txt +3 -1
- data/vendor/choosealicense.com/_licenses/cc0-1.0.txt +113 -105
- data/vendor/choosealicense.com/_licenses/cecill-2.1.txt +579 -0
- data/vendor/choosealicense.com/_licenses/ecl-2.0.txt +1 -2
- data/vendor/choosealicense.com/_licenses/epl-1.0.txt +1 -2
- data/vendor/choosealicense.com/_licenses/epl-2.0.txt +3 -4
- data/vendor/choosealicense.com/_licenses/eupl-1.1.txt +0 -1
- data/vendor/choosealicense.com/_licenses/eupl-1.2.txt +0 -1
- data/vendor/choosealicense.com/_licenses/gpl-2.0.txt +0 -1
- data/vendor/choosealicense.com/_licenses/gpl-3.0.txt +1 -2
- data/vendor/choosealicense.com/_licenses/isc.txt +0 -1
- data/vendor/choosealicense.com/_licenses/lgpl-2.1.txt +0 -1
- data/vendor/choosealicense.com/_licenses/lgpl-3.0.txt +1 -3
- data/vendor/choosealicense.com/_licenses/lppl-1.3c.txt +1 -2
- data/vendor/choosealicense.com/_licenses/mit.txt +1 -2
- data/vendor/choosealicense.com/_licenses/mpl-2.0.txt +0 -1
- data/vendor/choosealicense.com/_licenses/ms-pl.txt +0 -1
- data/vendor/choosealicense.com/_licenses/ms-rl.txt +0 -1
- data/vendor/choosealicense.com/_licenses/ncsa.txt +21 -22
- data/vendor/choosealicense.com/_licenses/odbl-1.0.txt +573 -0
- data/vendor/choosealicense.com/_licenses/ofl-1.1.txt +4 -2
- data/vendor/choosealicense.com/_licenses/osl-3.0.txt +1 -2
- data/vendor/choosealicense.com/_licenses/postgresql.txt +4 -5
- data/vendor/choosealicense.com/_licenses/unlicense.txt +1 -2
- data/vendor/choosealicense.com/_licenses/upl-1.0.txt +4 -5
- data/vendor/choosealicense.com/_licenses/vim.txt +111 -0
- data/vendor/choosealicense.com/_licenses/wtfpl.txt +0 -1
- data/vendor/choosealicense.com/_licenses/zlib.txt +4 -2
- metadata +77 -19
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe Licensee::HashHelper do
|
2
4
|
class HashHelperSpecFixture
|
3
5
|
include Licensee::HashHelper
|
@@ -53,7 +55,7 @@ RSpec.describe Licensee::HashHelper do
|
|
53
55
|
end
|
54
56
|
|
55
57
|
it 'does not expose other methods' do
|
56
|
-
expect(hash).
|
58
|
+
expect(hash).not_to have_key(:baz)
|
57
59
|
end
|
58
60
|
|
59
61
|
it 'calls to_h recursively' do
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe Licensee::LicenseField do
|
2
4
|
let(:expected_count) { 7 }
|
3
5
|
|
4
6
|
context 'class' do
|
5
7
|
it 'returns all license fields' do
|
6
8
|
expect(described_class.all.count).to eql(expected_count)
|
7
|
-
expect(described_class.all.first).to be_a(
|
9
|
+
expect(described_class.all.first).to be_a(described_class)
|
8
10
|
end
|
9
11
|
|
10
12
|
it 'returns all license field keys' do
|
@@ -33,7 +35,7 @@ RSpec.describe Licensee::LicenseField do
|
|
33
35
|
let(:fields) { described_class.from_array(array) }
|
34
36
|
|
35
37
|
it 'returns an array of LicenseFields' do
|
36
|
-
expect(fields.count).to
|
38
|
+
expect(fields.count).to be(2)
|
37
39
|
expect(fields.first).to be_a(described_class)
|
38
40
|
expect(fields.first.name).to eql('year')
|
39
41
|
expect(fields.last.name).to eql('fullname')
|
@@ -45,7 +47,7 @@ RSpec.describe Licensee::LicenseField do
|
|
45
47
|
let(:fields) { described_class.from_content(content) }
|
46
48
|
|
47
49
|
it 'pulls fields from content' do
|
48
|
-
expect(fields.count).to
|
50
|
+
expect(fields.count).to be(2)
|
49
51
|
expect(fields.first.key).to eql('year')
|
50
52
|
expect(fields[1].key).to eql('fullname')
|
51
53
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe Licensee::LicenseMeta do
|
2
4
|
subject { Licensee::License.find('mit').meta }
|
3
5
|
|
@@ -14,7 +16,7 @@ RSpec.describe Licensee::LicenseMeta do
|
|
14
16
|
|
15
17
|
it 'responds to the field as a hash key' do
|
16
18
|
if field['required']
|
17
|
-
expect(subject[name]).
|
19
|
+
expect(subject[name]).not_to be_nil
|
18
20
|
else
|
19
21
|
expect { subject[name] }.not_to raise_error
|
20
22
|
end
|
@@ -36,11 +38,12 @@ RSpec.describe Licensee::LicenseMeta do
|
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
39
|
-
|
41
|
+
describe '#from_hash' do
|
42
|
+
subject { described_class.from_hash(hash) }
|
43
|
+
|
40
44
|
let(:hash) do
|
41
45
|
{ 'title' => 'Test license', 'description' => 'A test license' }
|
42
46
|
end
|
43
|
-
subject { described_class.from_hash(hash) }
|
44
47
|
|
45
48
|
it 'sets values' do
|
46
49
|
expect(subject.title).to eql('Test license')
|
@@ -70,25 +73,26 @@ RSpec.describe Licensee::LicenseMeta do
|
|
70
73
|
end
|
71
74
|
end
|
72
75
|
|
73
|
-
|
74
|
-
let(:yaml) { "title: Test license\ndescription: A test license" }
|
76
|
+
describe '#from_yaml' do
|
75
77
|
subject { described_class.from_yaml(yaml) }
|
76
78
|
|
79
|
+
let(:yaml) { "title: Test license\ndescription: A test license" }
|
80
|
+
|
77
81
|
it 'parses yaml' do
|
78
82
|
expect(subject.title).to eql('Test license')
|
79
83
|
expect(subject.description).to eql('A test license')
|
80
84
|
end
|
81
85
|
|
82
86
|
it 'sets defaults' do
|
83
|
-
expect(subject.hidden).to
|
84
|
-
expect(subject.featured).to
|
87
|
+
expect(subject.hidden).to be(true)
|
88
|
+
expect(subject.featured).to be(false)
|
85
89
|
end
|
86
90
|
|
87
91
|
context 'nil yaml' do
|
88
92
|
let(:yaml) { nil }
|
89
93
|
|
90
94
|
it 'returns defaults' do
|
91
|
-
expect(subject.hidden).to
|
95
|
+
expect(subject.hidden).to be(true)
|
92
96
|
end
|
93
97
|
end
|
94
98
|
|
@@ -96,15 +100,15 @@ RSpec.describe Licensee::LicenseMeta do
|
|
96
100
|
let(:yaml) { '' }
|
97
101
|
|
98
102
|
it 'returns defaults' do
|
99
|
-
expect(subject.featured).to
|
103
|
+
expect(subject.featured).to be(false)
|
100
104
|
end
|
101
105
|
end
|
102
106
|
end
|
103
107
|
|
104
108
|
it 'returns the list of helper methods' do
|
105
|
-
expect(described_class.helper_methods.length).to
|
109
|
+
expect(described_class.helper_methods.length).to be(13)
|
106
110
|
expect(described_class.helper_methods).to include(:hidden?)
|
107
|
-
expect(described_class.helper_methods).
|
111
|
+
expect(described_class.helper_methods).not_to include(:hidden)
|
108
112
|
expect(described_class.helper_methods).to include(:title)
|
109
113
|
end
|
110
114
|
|
@@ -116,7 +120,7 @@ RSpec.describe Licensee::LicenseMeta do
|
|
116
120
|
'Babel' => 'https://github.com/babel/babel/blob/master/LICENSE'
|
117
121
|
},
|
118
122
|
{
|
119
|
-
'.NET Core' => 'https://github.com/dotnet/
|
123
|
+
'.NET Core' => 'https://github.com/dotnet/runtime/blob/master/LICENSE.TXT'
|
120
124
|
},
|
121
125
|
{
|
122
126
|
'Rails' => 'https://github.com/rails/rails/blob/master/MIT-LICENSE'
|
@@ -1,7 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe Licensee::LicenseRules do
|
2
|
-
let(:mit) { Licensee::License.find('mit') }
|
3
4
|
subject { mit.rules }
|
4
5
|
|
6
|
+
let(:mit) { Licensee::License.find('mit') }
|
7
|
+
|
5
8
|
Licensee::Rule.groups.each do |group|
|
6
9
|
context "the #{group} rule group" do
|
7
10
|
it 'responds as a hash key string' do
|
@@ -35,9 +38,10 @@ RSpec.describe Licensee::LicenseRules do
|
|
35
38
|
end
|
36
39
|
|
37
40
|
context 'created from a hash' do
|
38
|
-
let(:hash) { { 'permissions' => Licensee::Rule.all } }
|
39
41
|
subject { described_class.from_hash(hash) }
|
40
42
|
|
43
|
+
let(:hash) { { 'permissions' => Licensee::Rule.all } }
|
44
|
+
|
41
45
|
it 'exposes the rules' do
|
42
46
|
expect(subject.permissions.first.label).to eql('Commercial use')
|
43
47
|
end
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe Licensee::License do
|
2
|
-
let(:license_count) {
|
3
|
-
let(:hidden_license_count) {
|
4
|
+
let(:license_count) { 41 }
|
5
|
+
let(:hidden_license_count) { 28 }
|
4
6
|
let(:featured_license_count) { 3 }
|
5
7
|
let(:pseudo_license_count) { 2 }
|
6
8
|
let(:non_featured_license_count) do
|
@@ -14,7 +16,7 @@ RSpec.describe Licensee::License do
|
|
14
16
|
let(:no_license) { described_class.find('no-license') }
|
15
17
|
let(:gpl) { described_class.find('gpl-3.0') }
|
16
18
|
let(:lgpl) { described_class.find('lgpl-3.0') }
|
17
|
-
let(:content_hash) { '
|
19
|
+
let(:content_hash) { license_hashes['mit'] }
|
18
20
|
|
19
21
|
let(:license_dir) do
|
20
22
|
File.expand_path 'vendor/choosealicense.com/_licenses', project_root
|
@@ -33,7 +35,7 @@ RSpec.describe Licensee::License do
|
|
33
35
|
let(:arguments) { {} }
|
34
36
|
|
35
37
|
it 'returns the licenses' do
|
36
|
-
expect(licenses).to all be_a(
|
38
|
+
expect(licenses).to all be_a(described_class)
|
37
39
|
expect(licenses.count).to eql(license_count - hidden_license_count)
|
38
40
|
end
|
39
41
|
|
@@ -43,7 +45,8 @@ RSpec.describe Licensee::License do
|
|
43
45
|
|
44
46
|
it 'includes featured licenses' do
|
45
47
|
expect(licenses).to include(mit)
|
46
|
-
expect(licenses).
|
48
|
+
expect(licenses).not_to include(cc_by)
|
49
|
+
expect(licenses).not_to include(other)
|
47
50
|
end
|
48
51
|
end
|
49
52
|
|
@@ -62,7 +65,8 @@ RSpec.describe Licensee::License do
|
|
62
65
|
|
63
66
|
it 'includes only featured licenses' do
|
64
67
|
expect(licenses).to include(mit)
|
65
|
-
expect(licenses).
|
68
|
+
expect(licenses).not_to include(cc_by)
|
69
|
+
expect(licenses).not_to include(other)
|
66
70
|
expect(licenses.count).to eql(featured_license_count)
|
67
71
|
end
|
68
72
|
end
|
@@ -72,7 +76,8 @@ RSpec.describe Licensee::License do
|
|
72
76
|
|
73
77
|
it 'includes only non-featured licenses' do
|
74
78
|
expect(licenses).to include(unlicense)
|
75
|
-
expect(licenses).
|
79
|
+
expect(licenses).not_to include(mit)
|
80
|
+
expect(licenses).not_to include(other)
|
76
81
|
expect(licenses.count).to eql(non_featured_license_count)
|
77
82
|
end
|
78
83
|
|
@@ -82,33 +87,33 @@ RSpec.describe Licensee::License do
|
|
82
87
|
it 'includes only non-featured licenses' do
|
83
88
|
expect(licenses).to include(unlicense)
|
84
89
|
expect(licenses).to include(cc_by)
|
85
|
-
expect(licenses).
|
90
|
+
expect(licenses).not_to include(mit)
|
86
91
|
expect(licenses.count).to eql(license_count - featured_license_count)
|
87
92
|
end
|
88
93
|
end
|
89
94
|
end
|
90
95
|
|
91
|
-
context '
|
92
|
-
let(:other) {
|
96
|
+
context 'pseudo licenses' do
|
97
|
+
let(:other) { described_class.find('other') }
|
93
98
|
|
94
99
|
context 'by default' do
|
95
100
|
let(:arguments) { {} }
|
96
101
|
|
97
|
-
it "doesn't include
|
98
|
-
expect(licenses).
|
102
|
+
it "doesn't include pseudo licenses" do
|
103
|
+
expect(licenses).not_to include(other)
|
99
104
|
end
|
100
105
|
end
|
101
106
|
|
102
107
|
context 'with hidden licenses' do
|
103
108
|
let(:arguments) { { hidden: true } }
|
104
109
|
|
105
|
-
it 'includes
|
110
|
+
it 'includes pseudo licenses' do
|
106
111
|
expect(licenses).to include(other)
|
107
112
|
end
|
108
113
|
end
|
109
114
|
|
110
115
|
context 'when explicitly asked' do
|
111
|
-
let(:arguments) { { hidden: true,
|
116
|
+
let(:arguments) { { hidden: true, pseudo: true } }
|
112
117
|
|
113
118
|
it 'includes psudo licenses' do
|
114
119
|
expect(licenses).to include(other)
|
@@ -116,10 +121,28 @@ RSpec.describe Licensee::License do
|
|
116
121
|
end
|
117
122
|
|
118
123
|
context 'when explicitly excluded' do
|
119
|
-
let(:arguments) { { hidden: true,
|
124
|
+
let(:arguments) { { hidden: true, pseudo: false } }
|
120
125
|
|
121
126
|
it "doesn'tincludes psudo licenses" do
|
122
|
-
expect(licenses).
|
127
|
+
expect(licenses).not_to include(other)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
context 'mispelled' do
|
132
|
+
context 'when explicitly asked' do
|
133
|
+
let(:arguments) { { hidden: true, psuedo: true } }
|
134
|
+
|
135
|
+
it 'includes psudo licenses' do
|
136
|
+
expect(licenses).to include(other)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'when explicitly excluded' do
|
141
|
+
let(:arguments) { { hidden: true, psuedo: false } }
|
142
|
+
|
143
|
+
it "doesn'tincludes psudo licenses" do
|
144
|
+
expect(licenses).not_to include(other)
|
145
|
+
end
|
123
146
|
end
|
124
147
|
end
|
125
148
|
end
|
@@ -174,9 +197,9 @@ RSpec.describe Licensee::License do
|
|
174
197
|
expect(no_license.spdx_id).to eql('NONE')
|
175
198
|
end
|
176
199
|
|
177
|
-
|
200
|
+
describe '#other?' do
|
178
201
|
it 'knows MIT is not other' do
|
179
|
-
expect(gpl).
|
202
|
+
expect(gpl).not_to be_other
|
180
203
|
end
|
181
204
|
|
182
205
|
it 'knows the other license is other?' do
|
@@ -193,7 +216,7 @@ RSpec.describe Licensee::License do
|
|
193
216
|
end
|
194
217
|
|
195
218
|
it 'includes defaults' do
|
196
|
-
expect(other.meta['hidden']).to
|
219
|
+
expect(other.meta['hidden']).to be(true)
|
197
220
|
end
|
198
221
|
|
199
222
|
it 'returns the name' do
|
@@ -201,7 +224,8 @@ RSpec.describe Licensee::License do
|
|
201
224
|
end
|
202
225
|
|
203
226
|
it 'uses the default name when none exists' do
|
204
|
-
expect(other.name).to eql('
|
227
|
+
expect(other.name).to eql('Other')
|
228
|
+
expect(no_license.name).to eql('No license')
|
205
229
|
end
|
206
230
|
|
207
231
|
it 'expoeses the nickname' do
|
@@ -214,27 +238,27 @@ RSpec.describe Licensee::License do
|
|
214
238
|
end
|
215
239
|
|
216
240
|
it 'knows if a license is hidden' do
|
217
|
-
expect(mit).
|
241
|
+
expect(mit).not_to be_hidden
|
218
242
|
expect(cc_by).to be_hidden
|
219
243
|
end
|
220
244
|
|
221
245
|
it 'knows if a license is featured' do
|
222
246
|
expect(mit).to be_featured
|
223
|
-
expect(unlicense).
|
247
|
+
expect(unlicense).not_to be_featured
|
224
248
|
end
|
225
249
|
|
226
250
|
it 'knows if a license is GPL' do
|
227
|
-
expect(mit).
|
251
|
+
expect(mit).not_to be_gpl
|
228
252
|
expect(gpl).to be_gpl
|
229
253
|
end
|
230
254
|
|
231
255
|
it 'knows a license is lgpl' do
|
232
|
-
expect(mit).
|
256
|
+
expect(mit).not_to be_gpl
|
233
257
|
expect(lgpl).to be_lgpl
|
234
258
|
end
|
235
259
|
|
236
260
|
it 'knows if a license is CC' do
|
237
|
-
expect(gpl).
|
261
|
+
expect(gpl).not_to be_creative_commons
|
238
262
|
expect(cc_by).to be_creative_commons
|
239
263
|
end
|
240
264
|
end
|
@@ -277,11 +301,11 @@ RSpec.describe Licensee::License do
|
|
277
301
|
|
278
302
|
it 'knows equality' do
|
279
303
|
expect(mit).to eql(mit)
|
280
|
-
expect(gpl).
|
304
|
+
expect(gpl).not_to eql(mit)
|
281
305
|
end
|
282
306
|
|
283
307
|
it 'knows if a license is a pseudo license' do
|
284
|
-
expect(mit).
|
308
|
+
expect(mit).not_to be_pseudo_license
|
285
309
|
expect(other).to be_pseudo_license
|
286
310
|
end
|
287
311
|
|
@@ -295,24 +319,24 @@ RSpec.describe Licensee::License do
|
|
295
319
|
expect(mit.rules).to be_a(Licensee::LicenseRules)
|
296
320
|
expect(mit.rules).to have_key('permissions')
|
297
321
|
expect(mit.rules['permissions'].first).to be_a(Licensee::Rule)
|
298
|
-
expect(mit.rules.flatten.count).to
|
322
|
+
expect(mit.rules.flatten.count).to be(7)
|
299
323
|
end
|
300
324
|
|
301
325
|
it 'returns rules by tag and group' do
|
302
326
|
expect(cc_by.rules).to have_key('limitations')
|
303
327
|
rule = cc_by.rules['limitations'].find { |r| r.tag == 'patent-use' }
|
304
|
-
expect(rule).
|
328
|
+
expect(rule).not_to be_nil
|
305
329
|
expect(rule.description).to include('does NOT grant')
|
306
330
|
|
307
331
|
expect(gpl.rules).to have_key('permissions')
|
308
332
|
rule = gpl.rules['permissions'].find { |r| r.tag == 'patent-use' }
|
309
|
-
expect(rule).
|
333
|
+
expect(rule).not_to be_nil
|
310
334
|
expect(rule.description).to include('an express grant of patent rights')
|
311
335
|
end
|
312
336
|
|
313
337
|
context 'fields' do
|
314
338
|
it 'returns the license fields' do
|
315
|
-
expect(mit.fields.count).to
|
339
|
+
expect(mit.fields.count).to be(2)
|
316
340
|
expect(mit.fields.first.key).to eql('year')
|
317
341
|
expect(mit.fields.last.key).to eql('fullname')
|
318
342
|
expect(gpl.fields).to be_empty
|
@@ -329,19 +353,19 @@ RSpec.describe Licensee::License do
|
|
329
353
|
it 'returns mustache content' do
|
330
354
|
expect(license.content_for_mustache).to match(/{{{year}}}/)
|
331
355
|
expect(license.content_for_mustache).to match(/{{{fullname}}}/)
|
332
|
-
expect(license.content_for_mustache).
|
333
|
-
expect(license.content_for_mustache).
|
356
|
+
expect(license.content_for_mustache).not_to match(/\[year\]/)
|
357
|
+
expect(license.content_for_mustache).not_to match(/\[fullname\]/)
|
334
358
|
end
|
335
359
|
|
336
360
|
it "doesn't mangle other fields" do
|
337
361
|
expect(license.content_for_mustache).to match(/\[foo\]/)
|
338
|
-
expect(license.content_for_mustache).
|
362
|
+
expect(license.content_for_mustache).not_to match(/{{{foo}}}/)
|
339
363
|
end
|
340
364
|
end
|
341
365
|
end
|
342
366
|
|
343
367
|
context 'License.title_regex' do
|
344
|
-
|
368
|
+
described_class.all(hidden: true, pseudo: false).each do |license|
|
345
369
|
context "the #{license.title} license" do
|
346
370
|
%i[title nickname key].each do |variation|
|
347
371
|
next if license.send(variation).nil?
|
@@ -416,7 +440,7 @@ RSpec.describe Licensee::License do
|
|
416
440
|
|
417
441
|
context 'a license with an alt title' do
|
418
442
|
let(:text) { 'The Clear BSD license' }
|
419
|
-
let(:license) {
|
443
|
+
let(:license) { described_class.find('bsd-3-clause-clear') }
|
420
444
|
|
421
445
|
it 'matches' do
|
422
446
|
expect(text).to match(license.title_regex)
|
@@ -451,7 +475,7 @@ RSpec.describe Licensee::License do
|
|
451
475
|
end
|
452
476
|
|
453
477
|
context 'source regex' do
|
454
|
-
|
478
|
+
described_class.all(hidden: true, pseudo: false).each do |license|
|
455
479
|
context "the #{license.title} license" do
|
456
480
|
let(:source) { URI.parse(license.source) }
|
457
481
|
|
@@ -469,6 +493,7 @@ RSpec.describe Licensee::License do
|
|
469
493
|
context "with '#{suffix}' after the path" do
|
470
494
|
before do
|
471
495
|
next if license.key == 'wtfpl'
|
496
|
+
|
472
497
|
regex = /#{Licensee::License::SOURCE_SUFFIX}\z/
|
473
498
|
source.path = source.path.sub(regex, '')
|
474
499
|
source.path = "#{source.path}#{suffix}"
|
@@ -1,16 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe Licensee::Matchers::Cabal do
|
4
|
+
subject { described_class.new(file) }
|
5
|
+
|
2
6
|
let(:content) { 'license: mit' }
|
3
7
|
let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.txt') }
|
4
8
|
let(:mit) { Licensee::License.find('mit') }
|
5
9
|
let(:no_license) { Licensee::License.find('no-license') }
|
6
|
-
subject { described_class.new(file) }
|
7
10
|
|
8
11
|
it 'matches' do
|
9
12
|
expect(subject.match).to eql(mit)
|
10
13
|
end
|
11
14
|
|
12
15
|
it 'has a confidence' do
|
13
|
-
expect(subject.confidence).to
|
16
|
+
expect(subject.confidence).to be(90)
|
14
17
|
end
|
15
18
|
|
16
19
|
{
|
@@ -27,6 +30,98 @@ RSpec.describe Licensee::Matchers::Cabal do
|
|
27
30
|
end
|
28
31
|
end
|
29
32
|
|
33
|
+
context 'non-standard license format' do
|
34
|
+
let(:content) { "license: #{cabal_license}" }
|
35
|
+
|
36
|
+
context 'GPL-3' do
|
37
|
+
let(:cabal_license) { 'GPL-3' }
|
38
|
+
|
39
|
+
it 'returns GPL-3.0' do
|
40
|
+
expect(subject.match).to eql(Licensee::License.find('GPL-3.0'))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'GPL-2' do
|
45
|
+
let(:cabal_license) { 'GPL-2' }
|
46
|
+
|
47
|
+
it 'returns GPL-2.0' do
|
48
|
+
expect(subject.match).to eql(Licensee::License.find('GPL-2.0'))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'LGPL-2.1' do
|
53
|
+
let(:cabal_license) { 'LGPL-2.1' }
|
54
|
+
|
55
|
+
it 'returns LGPL-2.1' do
|
56
|
+
expect(subject.match).to eql(Licensee::License.find('LGPL-2.1'))
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'LGPL-3' do
|
61
|
+
let(:cabal_license) { 'LGPL-3' }
|
62
|
+
|
63
|
+
it 'returns LGPL-3.0' do
|
64
|
+
expect(subject.match).to eql(Licensee::License.find('LGPL-3.0'))
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'AGPL-3' do
|
69
|
+
let(:cabal_license) { 'AGPL-3' }
|
70
|
+
|
71
|
+
it 'returns AGPL-3.0' do
|
72
|
+
expect(subject.match).to eql(Licensee::License.find('AGPL-3.0'))
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'BSD2' do
|
77
|
+
let(:cabal_license) { 'BSD2' }
|
78
|
+
|
79
|
+
it 'returns BSD-2-Clause' do
|
80
|
+
expect(subject.match).to eql(Licensee::License.find('BSD-2-Clause'))
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'BSD3' do
|
85
|
+
let(:cabal_license) { 'BSD3' }
|
86
|
+
|
87
|
+
it 'returns BSD-3-Clause' do
|
88
|
+
expect(subject.match).to eql(Licensee::License.find('BSD-3-Clause'))
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'MIT' do
|
93
|
+
let(:cabal_license) { 'MIT' }
|
94
|
+
|
95
|
+
it 'returns MIT' do
|
96
|
+
expect(subject.match).to eql(Licensee::License.find('MIT'))
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'ISC' do
|
101
|
+
let(:cabal_license) { 'ISC' }
|
102
|
+
|
103
|
+
it 'returns ISC' do
|
104
|
+
expect(subject.match).to eql(Licensee::License.find('ISC'))
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'MPL-2.0' do
|
109
|
+
let(:cabal_license) { 'MPL-2.0' }
|
110
|
+
|
111
|
+
it 'returns MPL-2.0' do
|
112
|
+
expect(subject.match).to eql(Licensee::License.find('MPL-2.0'))
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
context 'Apache-2.0' do
|
117
|
+
let(:cabal_license) { 'Apache-2.0' }
|
118
|
+
|
119
|
+
it 'returns Apache-2.0' do
|
120
|
+
expect(subject.match).to eql(Licensee::License.find('Apache-2.0'))
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
30
125
|
context 'no license field' do
|
31
126
|
let(:content) { 'foo: bar' }
|
32
127
|
|