licensee 9.10.1 → 9.13.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +1 -1
  3. data/bin/licensee +5 -4
  4. data/lib/licensee.rb +7 -5
  5. data/lib/licensee/commands/detect.rb +7 -5
  6. data/lib/licensee/commands/diff.rb +7 -8
  7. data/lib/licensee/commands/license_path.rb +2 -0
  8. data/lib/licensee/commands/version.rb +2 -0
  9. data/lib/licensee/content_helper.rb +230 -85
  10. data/lib/licensee/hash_helper.rb +7 -5
  11. data/lib/licensee/license.rb +21 -22
  12. data/lib/licensee/license_field.rb +3 -1
  13. data/lib/licensee/license_meta.rb +2 -0
  14. data/lib/licensee/license_rules.rb +2 -0
  15. data/lib/licensee/matchers.rb +2 -0
  16. data/lib/licensee/matchers/cabal.rb +16 -2
  17. data/lib/licensee/matchers/cargo.rb +3 -1
  18. data/lib/licensee/matchers/copyright.rb +6 -4
  19. data/lib/licensee/matchers/cran.rb +5 -3
  20. data/lib/licensee/matchers/dice.rb +6 -4
  21. data/lib/licensee/matchers/dist_zilla.rb +3 -1
  22. data/lib/licensee/matchers/exact.rb +2 -0
  23. data/lib/licensee/matchers/gemspec.rb +7 -5
  24. data/lib/licensee/matchers/matcher.rb +3 -1
  25. data/lib/licensee/matchers/npm_bower.rb +3 -1
  26. data/lib/licensee/matchers/package.rb +2 -0
  27. data/lib/licensee/matchers/reference.rb +3 -1
  28. data/lib/licensee/matchers/spdx.rb +3 -1
  29. data/lib/licensee/project_files.rb +2 -0
  30. data/lib/licensee/project_files/license_file.rb +12 -10
  31. data/lib/licensee/project_files/package_manager_file.rb +2 -0
  32. data/lib/licensee/project_files/project_file.rb +12 -5
  33. data/lib/licensee/project_files/readme_file.rb +5 -3
  34. data/lib/licensee/projects.rb +2 -0
  35. data/lib/licensee/projects/fs_project.rb +9 -2
  36. data/lib/licensee/projects/git_project.rb +19 -11
  37. data/lib/licensee/projects/github_project.rb +3 -1
  38. data/lib/licensee/projects/project.rb +7 -5
  39. data/lib/licensee/rule.rb +2 -0
  40. data/lib/licensee/version.rb +3 -1
  41. data/licensee.gemspec +45 -0
  42. data/spec/bin_spec.rb +3 -1
  43. data/spec/fixture_spec.rb +46 -0
  44. data/spec/fixtures/bsd-3-noendorseslash/LICENSE +30 -0
  45. data/spec/fixtures/cc0-cal2013/LICENSE +116 -0
  46. data/spec/fixtures/cc0-cc/LICENSE +121 -0
  47. data/spec/fixtures/detect.json +10 -8
  48. data/spec/fixtures/fixtures.yml +134 -0
  49. data/spec/fixtures/html/license.html +262 -0
  50. data/spec/fixtures/license-hashes.json +41 -0
  51. data/spec/fixtures/mit-optional/LICENSE.txt +21 -0
  52. data/spec/fixtures/multiple-arrs/LICENSE +30 -0
  53. data/spec/fixtures/readme-invalid-encoding/README.md +24 -0
  54. data/spec/fixtures/unlicense-noinfo/LICENSE +22 -0
  55. data/spec/integration_spec.rb +68 -2
  56. data/spec/licensee/commands/detect_spec.rb +11 -7
  57. data/spec/licensee/commands/license_path_spec.rb +3 -1
  58. data/spec/licensee/commands/version_spec.rb +3 -1
  59. data/spec/licensee/content_helper_spec.rb +185 -67
  60. data/spec/licensee/hash_helper_spec.rb +3 -1
  61. data/spec/licensee/license_field_spec.rb +5 -3
  62. data/spec/licensee/license_meta_spec.rb +16 -12
  63. data/spec/licensee/license_rules_spec.rb +6 -2
  64. data/spec/licensee/license_spec.rb +37 -35
  65. data/spec/licensee/matchers/cabal_matcher_spec.rb +97 -2
  66. data/spec/licensee/matchers/cargo_matcher_spec.rb +5 -2
  67. data/spec/licensee/matchers/copyright_matcher_spec.rb +7 -5
  68. data/spec/licensee/matchers/cran_matcher_spec.rb +5 -2
  69. data/spec/licensee/matchers/dice_matcher_spec.rb +15 -12
  70. data/spec/licensee/matchers/dist_zilla_matcher_spec.rb +5 -2
  71. data/spec/licensee/matchers/exact_matcher_spec.rb +5 -2
  72. data/spec/licensee/matchers/gemspec_matcher_spec.rb +5 -2
  73. data/spec/licensee/matchers/matcher_spec.rb +6 -2
  74. data/spec/licensee/matchers/npm_bower_matcher_spec.rb +5 -3
  75. data/spec/licensee/matchers/package_matcher_spec.rb +6 -2
  76. data/spec/licensee/matchers/reference_matcher_spec.rb +4 -2
  77. data/spec/licensee/matchers/spdx_matcher_spec.rb +5 -2
  78. data/spec/licensee/project_files/license_file_spec.rb +20 -18
  79. data/spec/licensee/project_files/package_info_spec.rb +5 -1
  80. data/spec/licensee/project_files/project_file_spec.rb +8 -2
  81. data/spec/licensee/project_files/readme_file_spec.rb +4 -1
  82. data/spec/licensee/project_spec.rb +24 -17
  83. data/spec/licensee/projects/git_project_spec.rb +23 -0
  84. data/spec/licensee/projects/github_project_spec.rb +8 -5
  85. data/spec/licensee/rule_spec.rb +6 -3
  86. data/spec/licensee_spec.rb +12 -9
  87. data/spec/spec_helper.rb +27 -9
  88. data/spec/vendored_license_spec.rb +29 -10
  89. data/vendor/choosealicense.com/_data/meta.yml +0 -4
  90. data/vendor/choosealicense.com/_data/rules.yml +3 -0
  91. data/vendor/choosealicense.com/_licenses/0bsd.txt +39 -0
  92. data/vendor/choosealicense.com/_licenses/afl-3.0.txt +7 -6
  93. data/vendor/choosealicense.com/_licenses/agpl-3.0.txt +0 -1
  94. data/vendor/choosealicense.com/_licenses/apache-2.0.txt +1 -2
  95. data/vendor/choosealicense.com/_licenses/artistic-2.0.txt +1 -2
  96. data/vendor/choosealicense.com/_licenses/bsd-2-clause.txt +8 -6
  97. data/vendor/choosealicense.com/_licenses/bsd-3-clause-clear.txt +2 -2
  98. data/vendor/choosealicense.com/_licenses/bsd-3-clause.txt +12 -10
  99. data/vendor/choosealicense.com/_licenses/bsd-4-clause.txt +61 -0
  100. data/vendor/choosealicense.com/_licenses/bsl-1.0.txt +5 -2
  101. data/vendor/choosealicense.com/_licenses/cc-by-4.0.txt +16 -14
  102. data/vendor/choosealicense.com/_licenses/cc-by-sa-4.0.txt +16 -14
  103. data/vendor/choosealicense.com/_licenses/cc0-1.0.txt +113 -105
  104. data/vendor/choosealicense.com/_licenses/cecill-2.1.txt +579 -0
  105. data/vendor/choosealicense.com/_licenses/ecl-2.0.txt +1 -2
  106. data/vendor/choosealicense.com/_licenses/epl-1.0.txt +1 -2
  107. data/vendor/choosealicense.com/_licenses/epl-2.0.txt +3 -4
  108. data/vendor/choosealicense.com/_licenses/eupl-1.1.txt +0 -1
  109. data/vendor/choosealicense.com/_licenses/eupl-1.2.txt +0 -1
  110. data/vendor/choosealicense.com/_licenses/gpl-2.0.txt +0 -1
  111. data/vendor/choosealicense.com/_licenses/gpl-3.0.txt +1 -2
  112. data/vendor/choosealicense.com/_licenses/isc.txt +2 -3
  113. data/vendor/choosealicense.com/_licenses/lgpl-2.1.txt +0 -1
  114. data/vendor/choosealicense.com/_licenses/lgpl-3.0.txt +1 -3
  115. data/vendor/choosealicense.com/_licenses/lppl-1.3c.txt +1 -2
  116. data/vendor/choosealicense.com/_licenses/mit.txt +1 -2
  117. data/vendor/choosealicense.com/_licenses/mpl-2.0.txt +0 -1
  118. data/vendor/choosealicense.com/_licenses/ms-pl.txt +0 -1
  119. data/vendor/choosealicense.com/_licenses/ms-rl.txt +0 -1
  120. data/vendor/choosealicense.com/_licenses/ncsa.txt +21 -22
  121. data/vendor/choosealicense.com/_licenses/odbl-1.0.txt +573 -0
  122. data/vendor/choosealicense.com/_licenses/ofl-1.1.txt +4 -2
  123. data/vendor/choosealicense.com/_licenses/osl-3.0.txt +1 -2
  124. data/vendor/choosealicense.com/_licenses/postgresql.txt +4 -5
  125. data/vendor/choosealicense.com/_licenses/unlicense.txt +1 -2
  126. data/vendor/choosealicense.com/_licenses/upl-1.0.txt +4 -5
  127. data/vendor/choosealicense.com/_licenses/vim.txt +111 -0
  128. data/vendor/choosealicense.com/_licenses/wtfpl.txt +0 -1
  129. data/vendor/choosealicense.com/_licenses/zlib.txt +4 -2
  130. metadata +79 -28
@@ -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).to_not have_key(:baz)
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(Licensee::LicenseField)
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 eql(2)
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 eql(2)
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]).to_not be_nil
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
- context '#from_hash' do
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
- context '#from_yaml' do
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 eql(true)
84
- expect(subject.featured).to eql(false)
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 eql(true)
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 eql(false)
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 eql(13)
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).to_not include(:hidden)
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/corefx/blob/master/LICENSE.TXT'
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) { 36 }
3
- let(:hidden_license_count) { 24 }
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) { '46cdc03462b9af57968df67b450cc4372ac41f53' }
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(Licensee::License)
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,8 +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).to_not include(cc_by)
47
- expect(licenses).to_not include(other)
48
+ expect(licenses).not_to include(cc_by)
49
+ expect(licenses).not_to include(other)
48
50
  end
49
51
  end
50
52
 
@@ -63,8 +65,8 @@ RSpec.describe Licensee::License do
63
65
 
64
66
  it 'includes only featured licenses' do
65
67
  expect(licenses).to include(mit)
66
- expect(licenses).to_not include(cc_by)
67
- expect(licenses).to_not include(other)
68
+ expect(licenses).not_to include(cc_by)
69
+ expect(licenses).not_to include(other)
68
70
  expect(licenses.count).to eql(featured_license_count)
69
71
  end
70
72
  end
@@ -74,8 +76,8 @@ RSpec.describe Licensee::License do
74
76
 
75
77
  it 'includes only non-featured licenses' do
76
78
  expect(licenses).to include(unlicense)
77
- expect(licenses).to_not include(mit)
78
- expect(licenses).to_not include(other)
79
+ expect(licenses).not_to include(mit)
80
+ expect(licenses).not_to include(other)
79
81
  expect(licenses.count).to eql(non_featured_license_count)
80
82
  end
81
83
 
@@ -85,20 +87,20 @@ RSpec.describe Licensee::License do
85
87
  it 'includes only non-featured licenses' do
86
88
  expect(licenses).to include(unlicense)
87
89
  expect(licenses).to include(cc_by)
88
- expect(licenses).to_not include(mit)
90
+ expect(licenses).not_to include(mit)
89
91
  expect(licenses.count).to eql(license_count - featured_license_count)
90
92
  end
91
93
  end
92
94
  end
93
95
 
94
96
  context 'pseudo licenses' do
95
- let(:other) { Licensee::License.find('other') }
97
+ let(:other) { described_class.find('other') }
96
98
 
97
99
  context 'by default' do
98
100
  let(:arguments) { {} }
99
101
 
100
102
  it "doesn't include pseudo licenses" do
101
- expect(licenses).to_not include(other)
103
+ expect(licenses).not_to include(other)
102
104
  end
103
105
  end
104
106
 
@@ -122,7 +124,7 @@ RSpec.describe Licensee::License do
122
124
  let(:arguments) { { hidden: true, pseudo: false } }
123
125
 
124
126
  it "doesn'tincludes psudo licenses" do
125
- expect(licenses).to_not include(other)
127
+ expect(licenses).not_to include(other)
126
128
  end
127
129
  end
128
130
 
@@ -139,7 +141,7 @@ RSpec.describe Licensee::License do
139
141
  let(:arguments) { { hidden: true, psuedo: false } }
140
142
 
141
143
  it "doesn'tincludes psudo licenses" do
142
- expect(licenses).to_not include(other)
144
+ expect(licenses).not_to include(other)
143
145
  end
144
146
  end
145
147
  end
@@ -195,9 +197,9 @@ RSpec.describe Licensee::License do
195
197
  expect(no_license.spdx_id).to eql('NONE')
196
198
  end
197
199
 
198
- context '#other?' do
200
+ describe '#other?' do
199
201
  it 'knows MIT is not other' do
200
- expect(gpl).to_not be_other
202
+ expect(gpl).not_to be_other
201
203
  end
202
204
 
203
205
  it 'knows the other license is other?' do
@@ -214,7 +216,7 @@ RSpec.describe Licensee::License do
214
216
  end
215
217
 
216
218
  it 'includes defaults' do
217
- expect(other.meta['hidden']).to eql(true)
219
+ expect(other.meta['hidden']).to be(true)
218
220
  end
219
221
 
220
222
  it 'returns the name' do
@@ -236,27 +238,27 @@ RSpec.describe Licensee::License do
236
238
  end
237
239
 
238
240
  it 'knows if a license is hidden' do
239
- expect(mit).to_not be_hidden
241
+ expect(mit).not_to be_hidden
240
242
  expect(cc_by).to be_hidden
241
243
  end
242
244
 
243
245
  it 'knows if a license is featured' do
244
246
  expect(mit).to be_featured
245
- expect(unlicense).to_not be_featured
247
+ expect(unlicense).not_to be_featured
246
248
  end
247
249
 
248
250
  it 'knows if a license is GPL' do
249
- expect(mit).to_not be_gpl
251
+ expect(mit).not_to be_gpl
250
252
  expect(gpl).to be_gpl
251
253
  end
252
254
 
253
255
  it 'knows a license is lgpl' do
254
- expect(mit).to_not be_gpl
256
+ expect(mit).not_to be_gpl
255
257
  expect(lgpl).to be_lgpl
256
258
  end
257
259
 
258
260
  it 'knows if a license is CC' do
259
- expect(gpl).to_not be_creative_commons
261
+ expect(gpl).not_to be_creative_commons
260
262
  expect(cc_by).to be_creative_commons
261
263
  end
262
264
  end
@@ -299,11 +301,11 @@ RSpec.describe Licensee::License do
299
301
 
300
302
  it 'knows equality' do
301
303
  expect(mit).to eql(mit)
302
- expect(gpl).to_not eql(mit)
304
+ expect(gpl).not_to eql(mit)
303
305
  end
304
306
 
305
307
  it 'knows if a license is a pseudo license' do
306
- expect(mit).to_not be_pseudo_license
308
+ expect(mit).not_to be_pseudo_license
307
309
  expect(other).to be_pseudo_license
308
310
  end
309
311
 
@@ -317,24 +319,24 @@ RSpec.describe Licensee::License do
317
319
  expect(mit.rules).to be_a(Licensee::LicenseRules)
318
320
  expect(mit.rules).to have_key('permissions')
319
321
  expect(mit.rules['permissions'].first).to be_a(Licensee::Rule)
320
- expect(mit.rules.flatten.count).to eql(7)
322
+ expect(mit.rules.flatten.count).to be(7)
321
323
  end
322
324
 
323
325
  it 'returns rules by tag and group' do
324
326
  expect(cc_by.rules).to have_key('limitations')
325
327
  rule = cc_by.rules['limitations'].find { |r| r.tag == 'patent-use' }
326
- expect(rule).to_not be_nil
328
+ expect(rule).not_to be_nil
327
329
  expect(rule.description).to include('does NOT grant')
328
330
 
329
331
  expect(gpl.rules).to have_key('permissions')
330
332
  rule = gpl.rules['permissions'].find { |r| r.tag == 'patent-use' }
331
- expect(rule).to_not be_nil
333
+ expect(rule).not_to be_nil
332
334
  expect(rule.description).to include('an express grant of patent rights')
333
335
  end
334
336
 
335
337
  context 'fields' do
336
338
  it 'returns the license fields' do
337
- expect(mit.fields.count).to eql(2)
339
+ expect(mit.fields.count).to be(2)
338
340
  expect(mit.fields.first.key).to eql('year')
339
341
  expect(mit.fields.last.key).to eql('fullname')
340
342
  expect(gpl.fields).to be_empty
@@ -351,19 +353,19 @@ RSpec.describe Licensee::License do
351
353
  it 'returns mustache content' do
352
354
  expect(license.content_for_mustache).to match(/{{{year}}}/)
353
355
  expect(license.content_for_mustache).to match(/{{{fullname}}}/)
354
- expect(license.content_for_mustache).to_not match(/\[year\]/)
355
- expect(license.content_for_mustache).to_not match(/\[fullname\]/)
356
+ expect(license.content_for_mustache).not_to match(/\[year\]/)
357
+ expect(license.content_for_mustache).not_to match(/\[fullname\]/)
356
358
  end
357
359
 
358
360
  it "doesn't mangle other fields" do
359
361
  expect(license.content_for_mustache).to match(/\[foo\]/)
360
- expect(license.content_for_mustache).to_not match(/{{{foo}}}/)
362
+ expect(license.content_for_mustache).not_to match(/{{{foo}}}/)
361
363
  end
362
364
  end
363
365
  end
364
366
 
365
367
  context 'License.title_regex' do
366
- Licensee::License.all(hidden: true, pseudo: false).each do |license|
368
+ described_class.all(hidden: true, pseudo: false).each do |license|
367
369
  context "the #{license.title} license" do
368
370
  %i[title nickname key].each do |variation|
369
371
  next if license.send(variation).nil?
@@ -438,7 +440,7 @@ RSpec.describe Licensee::License do
438
440
 
439
441
  context 'a license with an alt title' do
440
442
  let(:text) { 'The Clear BSD license' }
441
- let(:license) { Licensee::License.find('bsd-3-clause-clear') }
443
+ let(:license) { described_class.find('bsd-3-clause-clear') }
442
444
 
443
445
  it 'matches' do
444
446
  expect(text).to match(license.title_regex)
@@ -473,7 +475,7 @@ RSpec.describe Licensee::License do
473
475
  end
474
476
 
475
477
  context 'source regex' do
476
- Licensee::License.all(hidden: true, pseudo: false).each do |license|
478
+ described_class.all(hidden: true, pseudo: false).each do |license|
477
479
  context "the #{license.title} license" do
478
480
  let(:source) { URI.parse(license.source) }
479
481
 
@@ -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 eql(90)
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