licensee 9.12.0 → 9.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +1 -1
  3. data/bin/licensee +4 -4
  4. data/lib/licensee.rb +3 -3
  5. data/lib/licensee/commands/detect.rb +6 -6
  6. data/lib/licensee/commands/diff.rb +2 -2
  7. data/lib/licensee/content_helper.rb +72 -26
  8. data/lib/licensee/hash_helper.rb +5 -5
  9. data/lib/licensee/license.rb +17 -21
  10. data/lib/licensee/matchers.rb +1 -0
  11. data/lib/licensee/matchers/cabal.rb +1 -1
  12. data/lib/licensee/matchers/cargo.rb +1 -1
  13. data/lib/licensee/matchers/copyright.rb +3 -3
  14. data/lib/licensee/matchers/dice.rb +4 -4
  15. data/lib/licensee/matchers/dist_zilla.rb +1 -1
  16. data/lib/licensee/matchers/gemspec.rb +4 -4
  17. data/lib/licensee/matchers/npm_bower.rb +5 -2
  18. data/lib/licensee/matchers/nuget.rb +43 -0
  19. data/lib/licensee/matchers/spdx.rb +1 -1
  20. data/lib/licensee/project_files/license_file.rb +3 -3
  21. data/lib/licensee/project_files/package_manager_file.rb +3 -2
  22. data/lib/licensee/project_files/project_file.rb +2 -1
  23. data/lib/licensee/projects/fs_project.rb +7 -2
  24. data/lib/licensee/projects/git_project.rb +3 -3
  25. data/lib/licensee/projects/github_project.rb +1 -1
  26. data/lib/licensee/projects/project.rb +3 -3
  27. data/lib/licensee/version.rb +1 -1
  28. data/licensee.gemspec +45 -0
  29. data/spec/bin_spec.rb +1 -1
  30. data/spec/fixture_spec.rb +5 -5
  31. data/spec/fixtures/bom/LICENSE.txt +21 -0
  32. data/spec/fixtures/bsd-3-noendorseslash/LICENSE +30 -0
  33. data/spec/fixtures/cc0-cal2013/LICENSE +116 -0
  34. data/spec/fixtures/cc0-cc/LICENSE +121 -0
  35. data/spec/fixtures/crlf-bsd/LICENSE.md +27 -0
  36. data/spec/fixtures/detect.json +14 -20
  37. data/spec/fixtures/fixtures.yml +43 -3
  38. data/spec/fixtures/license-hashes.json +10 -8
  39. data/spec/fixtures/markdown-artistic/LICENSE.md +192 -0
  40. data/spec/fixtures/multiple-arrs/LICENSE +30 -0
  41. data/spec/fixtures/readme-invalid-encoding/README.md +24 -0
  42. data/spec/fixtures/unlicense-noinfo/LICENSE +22 -0
  43. data/spec/fixtures/vim/LICENSE +78 -0
  44. data/spec/integration_spec.rb +87 -4
  45. data/spec/licensee/commands/detect_spec.rb +5 -5
  46. data/spec/licensee/commands/license_path_spec.rb +1 -1
  47. data/spec/licensee/commands/version_spec.rb +1 -1
  48. data/spec/licensee/content_helper_spec.rb +46 -50
  49. data/spec/licensee/hash_helper_spec.rb +23 -23
  50. data/spec/licensee/license_field_spec.rb +3 -3
  51. data/spec/licensee/license_meta_spec.rb +18 -22
  52. data/spec/licensee/license_rules_spec.rb +4 -2
  53. data/spec/licensee/license_spec.rb +43 -39
  54. data/spec/licensee/matchers/cabal_matcher_spec.rb +4 -2
  55. data/spec/licensee/matchers/cargo_matcher_spec.rb +3 -2
  56. data/spec/licensee/matchers/copyright_matcher_spec.rb +3 -3
  57. data/spec/licensee/matchers/cran_matcher_spec.rb +3 -2
  58. data/spec/licensee/matchers/dice_matcher_spec.rb +15 -21
  59. data/spec/licensee/matchers/dist_zilla_matcher_spec.rb +3 -2
  60. data/spec/licensee/matchers/exact_matcher_spec.rb +3 -2
  61. data/spec/licensee/matchers/gemspec_matcher_spec.rb +3 -2
  62. data/spec/licensee/matchers/matcher_spec.rb +10 -8
  63. data/spec/licensee/matchers/npm_bower_matcher_spec.rb +12 -3
  64. data/spec/licensee/matchers/nu_get_matcher_spec.rb +91 -0
  65. data/spec/licensee/matchers/package_matcher_spec.rb +4 -2
  66. data/spec/licensee/matchers/reference_matcher_spec.rb +2 -2
  67. data/spec/licensee/matchers/spdx_matcher_spec.rb +3 -2
  68. data/spec/licensee/project_files/license_file_spec.rb +43 -42
  69. data/spec/licensee/project_files/package_info_spec.rb +11 -1
  70. data/spec/licensee/project_files/project_file_spec.rb +5 -2
  71. data/spec/licensee/project_files/readme_file_spec.rb +2 -1
  72. data/spec/licensee/project_spec.rb +22 -17
  73. data/spec/licensee/projects/github_project_spec.rb +6 -5
  74. data/spec/licensee/rule_spec.rb +5 -4
  75. data/spec/licensee_spec.rb +10 -9
  76. data/spec/spec_helper.rb +2 -2
  77. data/spec/vendored_license_spec.rb +5 -5
  78. data/vendor/choosealicense.com/_data/meta.yml +1 -1
  79. data/vendor/choosealicense.com/_data/rules.yml +15 -12
  80. data/vendor/choosealicense.com/_licenses/0bsd.txt +3 -3
  81. data/vendor/choosealicense.com/_licenses/apache-2.0.txt +4 -4
  82. data/vendor/choosealicense.com/_licenses/artistic-2.0.txt +1 -1
  83. data/vendor/choosealicense.com/_licenses/bsd-2-clause.txt +3 -3
  84. data/vendor/choosealicense.com/_licenses/bsd-3-clause-clear.txt +1 -0
  85. data/vendor/choosealicense.com/_licenses/bsd-3-clause.txt +3 -3
  86. data/vendor/choosealicense.com/_licenses/bsd-4-clause.txt +61 -0
  87. data/vendor/choosealicense.com/_licenses/bsl-1.0.txt +5 -1
  88. data/vendor/choosealicense.com/_licenses/cc-by-4.0.txt +16 -13
  89. data/vendor/choosealicense.com/_licenses/cc-by-sa-4.0.txt +16 -13
  90. data/vendor/choosealicense.com/_licenses/cc0-1.0.txt +113 -104
  91. data/vendor/choosealicense.com/_licenses/cecill-2.1.txt +6 -6
  92. data/vendor/choosealicense.com/_licenses/ecl-2.0.txt +4 -4
  93. data/vendor/choosealicense.com/_licenses/epl-1.0.txt +3 -3
  94. data/vendor/choosealicense.com/_licenses/epl-2.0.txt +5 -5
  95. data/vendor/choosealicense.com/_licenses/eupl-1.2.txt +3 -3
  96. data/vendor/choosealicense.com/_licenses/gpl-2.0.txt +3 -3
  97. data/vendor/choosealicense.com/_licenses/gpl-3.0.txt +4 -4
  98. data/vendor/choosealicense.com/_licenses/isc.txt +3 -3
  99. data/vendor/choosealicense.com/_licenses/lgpl-3.0.txt +0 -1
  100. data/vendor/choosealicense.com/_licenses/lppl-1.3c.txt +1 -1
  101. data/vendor/choosealicense.com/_licenses/mit.txt +3 -3
  102. data/vendor/choosealicense.com/_licenses/mpl-2.0.txt +3 -3
  103. data/vendor/choosealicense.com/_licenses/ncsa.txt +24 -24
  104. data/vendor/choosealicense.com/_licenses/odbl-1.0.txt +3 -3
  105. data/vendor/choosealicense.com/_licenses/ofl-1.1.txt +4 -1
  106. data/vendor/choosealicense.com/_licenses/osl-3.0.txt +3 -3
  107. data/vendor/choosealicense.com/_licenses/postgresql.txt +5 -5
  108. data/vendor/choosealicense.com/_licenses/unlicense.txt +3 -3
  109. data/vendor/choosealicense.com/_licenses/upl-1.0.txt +4 -4
  110. data/vendor/choosealicense.com/_licenses/vim.txt +111 -0
  111. data/vendor/choosealicense.com/_licenses/zlib.txt +4 -1
  112. metadata +62 -21
@@ -1,18 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe Licensee::Matchers::Cabal 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(:no_license) { Licensee::License.find('no-license') }
8
- subject { described_class.new(file) }
9
10
 
10
11
  it 'matches' do
11
12
  expect(subject.match).to eql(mit)
12
13
  end
13
14
 
14
15
  it 'has a confidence' do
15
- expect(subject.confidence).to eql(90)
16
+ expect(subject.confidence).to be(90)
16
17
  end
17
18
 
18
19
  {
@@ -31,6 +32,7 @@ RSpec.describe Licensee::Matchers::Cabal do
31
32
 
32
33
  context 'non-standard license format' do
33
34
  let(:content) { "license: #{cabal_license}" }
35
+
34
36
  context 'GPL-3' do
35
37
  let(:cabal_license) { 'GPL-3' }
36
38
 
@@ -1,17 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe Licensee::Matchers::Cargo 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, 'Cargo.toml') }
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 eql(90)
15
+ expect(subject.confidence).to be(90)
15
16
  end
16
17
 
17
18
  it 'matches' do
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe Licensee::Matchers::Copyright do
4
+ subject { described_class.new(file) }
5
+
4
6
  let(:content) { 'Copyright 2015 Ben Balter'.dup }
5
7
  let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.txt') }
6
8
  let(:mit) { Licensee::License.find('mit') }
7
9
  let(:no_license) { Licensee::License.find('no-license') }
8
10
 
9
- subject { described_class.new(file) }
10
-
11
11
  it 'stores the file' do
12
12
  expect(subject.file).to eql(file)
13
13
  end
@@ -17,7 +17,7 @@ RSpec.describe Licensee::Matchers::Copyright do
17
17
  end
18
18
 
19
19
  it 'has a confidence' do
20
- expect(subject.confidence).to eql(100)
20
+ expect(subject.confidence).to be(100)
21
21
  end
22
22
 
23
23
  {
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe Licensee::Matchers::Cran do
4
+ subject { described_class.new(file) }
5
+
4
6
  let(:mit) { Licensee::License.find('mit') }
5
7
  let(:gpl2) { Licensee::License.find('gpl-2.0') }
6
8
  let(:gpl3) { Licensee::License.find('gpl-3.0') }
7
9
  let(:content) { "License: MIT + file LICENSE\nPackage: test" }
8
10
  let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'DESCRIPTION') }
9
- subject { described_class.new(file) }
10
11
 
11
12
  it 'stores the file' do
12
13
  expect(subject.file).to eql(file)
@@ -17,7 +18,7 @@ RSpec.describe Licensee::Matchers::Cran do
17
18
  end
18
19
 
19
20
  it 'is confident' do
20
- expect(subject.confidence).to eql(90)
21
+ expect(subject.confidence).to be(90)
21
22
  end
22
23
 
23
24
  {
@@ -1,14 +1,16 @@
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') }
9
+ let(:lgpl) { Licensee::License.find('lgpl-2.1') }
7
10
  let(:cc_by) { Licensee::License.find('cc-by-4.0') }
8
11
  let(:cc_by_sa) { Licensee::License.find('cc-by-sa-4.0') }
9
12
  let(:content) { sub_copyright_info(gpl) }
10
13
  let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.txt') }
11
- subject { described_class.new(file) }
12
14
 
13
15
  it 'stores the file' do
14
16
  expect(subject.file).to eql(file)
@@ -18,44 +20,36 @@ RSpec.describe Licensee::Matchers::Dice do
18
20
  expect(subject.match).to eql(gpl)
19
21
  end
20
22
 
21
- it 'builds a list of potential licenses' do
22
- expect(subject.potential_matches).to eql([agpl, gpl])
23
- end
24
-
25
23
  it 'sorts licenses by similarity' do
26
24
  expect(subject.matches_by_similarity[0]).to eql([gpl, 100.0])
27
- expect(subject.matches_by_similarity[1]).to eql([agpl, 95.67966280295047])
28
- end
29
-
30
- it 'returns a list of licenses above the confidence threshold' do
31
- expect(subject.matches_by_similarity[0]).to eql([gpl, 100.0])
32
- expect(subject.matches_by_similarity[1]).to eql([agpl, 95.67966280295047])
25
+ expect(subject.matches_by_similarity[1]).to eql([agpl, 95.28301886792453])
26
+ expect(subject.matches_by_similarity[2]).to eql([lgpl, 39.33253873659118])
33
27
  end
34
28
 
35
29
  it 'returns the match confidence' do
36
- expect(subject.confidence).to eql(100.0)
30
+ expect(subject.confidence).to be(100.0)
37
31
  end
38
32
 
39
33
  context 'without a match' do
40
34
  let(:content) { 'Not really a license' }
41
35
 
42
36
  it "doesn't match" do
43
- expect(subject.match).to eql(nil)
37
+ expect(subject.match).to be(nil)
44
38
  expect(subject.matches).to be_empty
45
- expect(subject.confidence).to eql(0)
39
+ expect(subject.confidence).to be(0)
46
40
  end
47
41
  end
48
42
 
49
43
  context 'stacked licenses' do
50
44
  let(:content) do
51
- sub_copyright_info(mit) + "\n\n" + sub_copyright_info(gpl)
45
+ "#{sub_copyright_info(mit)}\n\n#{sub_copyright_info(gpl)}"
52
46
  end
53
47
 
54
48
  it "doesn't match" do
55
- expect(content).to_not be_detected_as(gpl)
56
- expect(subject.match).to eql(nil)
49
+ expect(content).not_to be_detected_as(gpl)
50
+ expect(subject.match).to be(nil)
57
51
  expect(subject.matches).to be_empty
58
- expect(subject.confidence).to eql(0)
52
+ expect(subject.confidence).to be(0)
59
53
  end
60
54
  end
61
55
 
@@ -74,11 +68,11 @@ RSpec.describe Licensee::Matchers::Dice do
74
68
  let(:content) { File.read(license_path) }
75
69
 
76
70
  it "doesn't match" do
77
- expect(content).to_not be_detected_as(cc_by)
78
- expect(content).to_not be_detected_as(cc_by_sa)
71
+ expect(content).not_to be_detected_as(cc_by)
72
+ expect(content).not_to be_detected_as(cc_by_sa)
79
73
  expect(subject.match).to be_nil
80
74
  expect(subject.matches).to be_empty
81
- expect(subject.confidence).to eql(0)
75
+ expect(subject.confidence).to be(0)
82
76
  end
83
77
  end
84
78
  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 eql(90)
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 eql(100)
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 eql(90)
17
+ expect(subject.confidence).to be(90)
17
18
  end
18
19
 
19
20
  {
@@ -1,27 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ class MatcherSpecFixture < Licensee::Matchers::Matcher
4
+ def confidence
5
+ 0
6
+ end
7
+ end
8
+
3
9
  RSpec.describe Licensee::Matchers::Matcher do
10
+ subject { described_class.new(file) }
11
+
4
12
  let(:mit) { Licensee::License.find('mit') }
5
13
  let(:content) { sub_copyright_info(mit) }
6
14
  let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.txt') }
7
- subject { described_class.new(file) }
8
15
 
9
16
  it 'stores the file' do
10
17
  expect(subject.file).to eql(file)
11
18
  end
12
19
 
13
20
  it 'returns its name' do
14
- expect(subject.name).to eql(:matcher)
21
+ expect(subject.name).to be(:matcher)
15
22
  end
16
23
 
17
24
  context 'to_h' do
18
- class MatcherSpecFixture < Licensee::Matchers::Matcher
19
- def confidence
20
- 0
21
- end
22
- end
23
-
24
25
  subject { MatcherSpecFixture.new(file) }
26
+
25
27
  let(:hash) { subject.to_h }
26
28
  let(:expected) do
27
29
  {
@@ -1,19 +1,20 @@
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
-
9
- subject { described_class.new(file) }
10
+ let(:no_license) { Licensee::License.find('no-license') }
10
11
 
11
12
  it 'matches' do
12
13
  expect(subject.match).to eql(mit)
13
14
  end
14
15
 
15
16
  it 'has a confidence' do
16
- expect(subject.confidence).to eql(90)
17
+ expect(subject.confidence).to be(90)
17
18
  end
18
19
 
19
20
  {
@@ -56,4 +57,12 @@ RSpec.describe Licensee::Matchers::NpmBower do
56
57
  expect(subject.match).to eql(other)
57
58
  end
58
59
  end
60
+
61
+ context 'UNLICENSED' do
62
+ let(:content) { "'license': 'UNLICENSED'" }
63
+
64
+ it 'returns none' do
65
+ expect(subject.match).to eql(no_license)
66
+ end
67
+ end
59
68
  end
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Licensee::Matchers::NuGet do
4
+ subject { described_class.new(file) }
5
+
6
+ let(:content) { '<license type="expression">mit</license>' }
7
+ let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'foo.nuspec') }
8
+ let(:mit) { Licensee::License.find('mit') }
9
+ let(:apache2) { Licensee::License.find('apache-2.0') }
10
+ let(:other) { Licensee::License.find('other') }
11
+
12
+ it 'matches' do
13
+ expect(subject.match).to eql(mit)
14
+ end
15
+
16
+ it 'has a confidence' do
17
+ expect(subject.confidence).to be(90)
18
+ end
19
+
20
+ {
21
+ 'double quotes' => '<license type="expression">mit</license>',
22
+ 'single quotes' => "<license type='expression'>mit</license>",
23
+ 'whitespace' => '<license type = "expression" >mit</license >',
24
+ 'leading whitespace' => ' <license type="expression">mit</license>'
25
+ }.each do |description, license_declaration|
26
+ context "with a #{description} license element" do
27
+ let(:content) { license_declaration }
28
+
29
+ it 'matches' do
30
+ expect(subject.match).to eql(mit)
31
+ end
32
+ end
33
+ end
34
+
35
+ context 'no license field' do
36
+ let(:content) { '<file>wrongelement</file>' }
37
+
38
+ it 'returns nil' do
39
+ expect(subject.match).to be_nil
40
+ end
41
+ end
42
+
43
+ context 'an unknown license' do
44
+ let(:content) { '<license type="expression">foo</license>' }
45
+
46
+ it 'returns other' do
47
+ expect(subject.match).to eql(other)
48
+ end
49
+ end
50
+
51
+ context 'a license expression' do
52
+ let(:content) { '<license type="expression">BSD-2-Clause OR MIT</license>' }
53
+
54
+ it 'returns other' do
55
+ expect(subject.match).to eql(other)
56
+ end
57
+ end
58
+
59
+ {
60
+ 'nuget' => '<licenseUrl>https://licenses.nuget.org/Apache-2.0</licenseUrl>',
61
+ 'nuget (http)' => '<licenseUrl>http://licenses.nuget.org/Apache-2.0</licenseUrl>',
62
+ 'opensource' => '<licenseUrl>https://opensource.org/licenses/Apache-2.0</licenseUrl>',
63
+ 'opensource (www)' => '<licenseUrl>http://www.opensource.org/licenses/Apache-2.0</licenseUrl>',
64
+ 'spdx' => '<licenseUrl>https://spdx.org/licenses/Apache-2.0</licenseUrl>',
65
+ 'spdx (www)' => '<licenseUrl>http://www.spdx.org/licenses/Apache-2.0</licenseUrl>',
66
+ 'spdx (html)' => '<licenseUrl>https://spdx.org/licenses/Apache-2.0.html</licenseUrl>',
67
+ 'spdx (txt)' => '<licenseUrl>https://spdx.org/licenses/Apache-2.0.txt</licenseUrl>'
68
+ }.each do |description, license_declaration|
69
+ context "with a #{description} licenseUrl element containing SPDX" do
70
+ let(:content) { license_declaration }
71
+
72
+ it 'matches' do
73
+ expect(subject.match).to eql(apache2)
74
+ end
75
+ end
76
+ end
77
+
78
+ {
79
+ '2.0 (https)' => '<licenseUrl>https://apache.org/licenses/LICENSE-2.0</licenseUrl>',
80
+ '2.0 (http/www)' => '<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl>',
81
+ '2.0 (txt)' => '<licenseUrl>https://apache.org/licenses/LICENSE-2.0.txt</licenseUrl>'
82
+ }.each do |description, license_declaration|
83
+ context "with an apache.org #{description} licenseUrl element" do
84
+ let(:content) { license_declaration }
85
+
86
+ it 'matches' do
87
+ expect(subject.match).to eql(apache2)
88
+ end
89
+ end
90
+ end
91
+ end
@@ -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
- subject { described_class.new(file) }
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 eql(90)
22
+ expect(subject.confidence).to be(90)
21
23
  end
22
24
 
23
25
  context 'with a nil license property' do