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,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 eql(90)
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 eql(91)
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' => 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
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).to_not match('.md2')
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).to_not match('.md/foo')
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).to_not match('.md/foo')
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).to_not match(regex)
162
- expect(subject).to_not be_a_potential_false_positive
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 without creative commons in the title' do
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
- <<-LICENSE
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).to_not be_lgpl
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).to_not be_lgpl
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).to_not be_gpl
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 eql(100)
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 eql(2)
105
+ expect(files.count).to be(2)
102
106
  license = files.find { |f| f[:name] == 'LICENSE.txt' }
103
- expect(license).to_not be_nil
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 eql(1)
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 eql(0)
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 eql(2)
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 eql(2)
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 eql(2)
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).to_not be_nil
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).to_not be_nil
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 eql(2)
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 eql(2)
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 eql(2)
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 'should set @repo' do
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 'should set @repo, stripping the trailing extension' do
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 'should raise an ArgumentError' do
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 'should raise an ArgumentError' do
38
+ it 'raises an ArgumentError' do
38
39
  expect { instance }.to raise_error(ArgumentError)
39
40
  end
40
41
  end