licensee 9.10.0 → 9.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/bin/licensee +5 -4
  3. data/lib/licensee.rb +4 -2
  4. data/lib/licensee/commands/detect.rb +10 -5
  5. data/lib/licensee/commands/diff.rb +7 -8
  6. data/lib/licensee/commands/license_path.rb +2 -0
  7. data/lib/licensee/commands/version.rb +2 -0
  8. data/lib/licensee/content_helper.rb +234 -85
  9. data/lib/licensee/hash_helper.rb +7 -5
  10. data/lib/licensee/license.rb +32 -25
  11. data/lib/licensee/license_field.rb +4 -1
  12. data/lib/licensee/license_meta.rb +3 -0
  13. data/lib/licensee/license_rules.rb +2 -0
  14. data/lib/licensee/matchers.rb +2 -0
  15. data/lib/licensee/matchers/cabal.rb +16 -2
  16. data/lib/licensee/matchers/cargo.rb +3 -1
  17. data/lib/licensee/matchers/copyright.rb +6 -4
  18. data/lib/licensee/matchers/cran.rb +7 -3
  19. data/lib/licensee/matchers/dice.rb +6 -4
  20. data/lib/licensee/matchers/dist_zilla.rb +3 -1
  21. data/lib/licensee/matchers/exact.rb +3 -0
  22. data/lib/licensee/matchers/gemspec.rb +8 -5
  23. data/lib/licensee/matchers/matcher.rb +3 -1
  24. data/lib/licensee/matchers/npm_bower.rb +3 -1
  25. data/lib/licensee/matchers/package.rb +3 -0
  26. data/lib/licensee/matchers/reference.rb +3 -1
  27. data/lib/licensee/matchers/spdx.rb +3 -1
  28. data/lib/licensee/project_files.rb +2 -0
  29. data/lib/licensee/project_files/license_file.rb +13 -10
  30. data/lib/licensee/project_files/package_manager_file.rb +3 -0
  31. data/lib/licensee/project_files/project_file.rb +12 -4
  32. data/lib/licensee/project_files/readme_file.rb +5 -3
  33. data/lib/licensee/projects.rb +2 -0
  34. data/lib/licensee/projects/fs_project.rb +3 -0
  35. data/lib/licensee/projects/git_project.rb +19 -11
  36. data/lib/licensee/projects/github_project.rb +6 -1
  37. data/lib/licensee/projects/project.rb +16 -5
  38. data/lib/licensee/rule.rb +2 -0
  39. data/lib/licensee/version.rb +3 -1
  40. data/licensee.gemspec +47 -0
  41. data/spec/bin_spec.rb +3 -1
  42. data/spec/fixture_spec.rb +46 -0
  43. data/spec/fixtures/bsd-3-noendorseslash/LICENSE +30 -0
  44. data/spec/fixtures/cc0-cal2013/LICENSE +116 -0
  45. data/spec/fixtures/cc0-cc/LICENSE +121 -0
  46. data/spec/fixtures/detect.json +9 -7
  47. data/spec/fixtures/fixtures.yml +130 -0
  48. data/spec/fixtures/html/license.html +262 -0
  49. data/spec/fixtures/license-hashes.json +41 -0
  50. data/spec/fixtures/mit-optional/LICENSE.txt +21 -0
  51. data/spec/fixtures/multiple-arrs/LICENSE +30 -0
  52. data/spec/fixtures/unlicense-noinfo/LICENSE +22 -0
  53. data/spec/integration_spec.rb +68 -2
  54. data/spec/licensee/commands/detect_spec.rb +10 -6
  55. data/spec/licensee/commands/license_path_spec.rb +3 -1
  56. data/spec/licensee/commands/version_spec.rb +3 -1
  57. data/spec/licensee/content_helper_spec.rb +184 -67
  58. data/spec/licensee/hash_helper_spec.rb +3 -1
  59. data/spec/licensee/license_field_spec.rb +5 -3
  60. data/spec/licensee/license_meta_spec.rb +16 -12
  61. data/spec/licensee/license_rules_spec.rb +6 -2
  62. data/spec/licensee/license_spec.rb +62 -37
  63. data/spec/licensee/matchers/cabal_matcher_spec.rb +97 -2
  64. data/spec/licensee/matchers/cargo_matcher_spec.rb +5 -2
  65. data/spec/licensee/matchers/copyright_matcher_spec.rb +7 -5
  66. data/spec/licensee/matchers/cran_matcher_spec.rb +5 -2
  67. data/spec/licensee/matchers/dice_matcher_spec.rb +15 -12
  68. data/spec/licensee/matchers/dist_zilla_matcher_spec.rb +5 -2
  69. data/spec/licensee/matchers/exact_matcher_spec.rb +5 -2
  70. data/spec/licensee/matchers/gemspec_matcher_spec.rb +5 -2
  71. data/spec/licensee/matchers/matcher_spec.rb +6 -2
  72. data/spec/licensee/matchers/npm_bower_matcher_spec.rb +5 -3
  73. data/spec/licensee/matchers/package_matcher_spec.rb +6 -2
  74. data/spec/licensee/matchers/reference_matcher_spec.rb +4 -2
  75. data/spec/licensee/matchers/spdx_matcher_spec.rb +5 -2
  76. data/spec/licensee/project_files/license_file_spec.rb +20 -18
  77. data/spec/licensee/project_files/package_info_spec.rb +5 -1
  78. data/spec/licensee/project_files/project_file_spec.rb +8 -2
  79. data/spec/licensee/project_files/readme_file_spec.rb +4 -1
  80. data/spec/licensee/project_spec.rb +24 -17
  81. data/spec/licensee/projects/git_project_spec.rb +23 -0
  82. data/spec/licensee/projects/github_project_spec.rb +8 -5
  83. data/spec/licensee/rule_spec.rb +6 -3
  84. data/spec/licensee_spec.rb +12 -9
  85. data/spec/spec_helper.rb +28 -9
  86. data/spec/vendored_license_spec.rb +29 -10
  87. data/vendor/choosealicense.com/_data/meta.yml +0 -4
  88. data/vendor/choosealicense.com/_data/rules.yml +3 -0
  89. data/vendor/choosealicense.com/_licenses/0bsd.txt +39 -0
  90. data/vendor/choosealicense.com/_licenses/afl-3.0.txt +7 -6
  91. data/vendor/choosealicense.com/_licenses/agpl-3.0.txt +0 -1
  92. data/vendor/choosealicense.com/_licenses/apache-2.0.txt +1 -2
  93. data/vendor/choosealicense.com/_licenses/artistic-2.0.txt +1 -2
  94. data/vendor/choosealicense.com/_licenses/bsd-2-clause.txt +8 -6
  95. data/vendor/choosealicense.com/_licenses/bsd-3-clause-clear.txt +2 -2
  96. data/vendor/choosealicense.com/_licenses/bsd-3-clause.txt +12 -10
  97. data/vendor/choosealicense.com/_licenses/bsd-4-clause.txt +61 -0
  98. data/vendor/choosealicense.com/_licenses/bsl-1.0.txt +5 -2
  99. data/vendor/choosealicense.com/_licenses/cc-by-4.0.txt +3 -1
  100. data/vendor/choosealicense.com/_licenses/cc-by-sa-4.0.txt +3 -1
  101. data/vendor/choosealicense.com/_licenses/cc0-1.0.txt +113 -105
  102. data/vendor/choosealicense.com/_licenses/cecill-2.1.txt +579 -0
  103. data/vendor/choosealicense.com/_licenses/ecl-2.0.txt +1 -2
  104. data/vendor/choosealicense.com/_licenses/epl-1.0.txt +1 -2
  105. data/vendor/choosealicense.com/_licenses/epl-2.0.txt +3 -4
  106. data/vendor/choosealicense.com/_licenses/eupl-1.1.txt +0 -1
  107. data/vendor/choosealicense.com/_licenses/eupl-1.2.txt +0 -1
  108. data/vendor/choosealicense.com/_licenses/gpl-2.0.txt +0 -1
  109. data/vendor/choosealicense.com/_licenses/gpl-3.0.txt +1 -2
  110. data/vendor/choosealicense.com/_licenses/isc.txt +0 -1
  111. data/vendor/choosealicense.com/_licenses/lgpl-2.1.txt +0 -1
  112. data/vendor/choosealicense.com/_licenses/lgpl-3.0.txt +1 -3
  113. data/vendor/choosealicense.com/_licenses/lppl-1.3c.txt +1 -2
  114. data/vendor/choosealicense.com/_licenses/mit.txt +1 -2
  115. data/vendor/choosealicense.com/_licenses/mpl-2.0.txt +0 -1
  116. data/vendor/choosealicense.com/_licenses/ms-pl.txt +0 -1
  117. data/vendor/choosealicense.com/_licenses/ms-rl.txt +0 -1
  118. data/vendor/choosealicense.com/_licenses/ncsa.txt +21 -22
  119. data/vendor/choosealicense.com/_licenses/odbl-1.0.txt +573 -0
  120. data/vendor/choosealicense.com/_licenses/ofl-1.1.txt +4 -2
  121. data/vendor/choosealicense.com/_licenses/osl-3.0.txt +1 -2
  122. data/vendor/choosealicense.com/_licenses/postgresql.txt +4 -5
  123. data/vendor/choosealicense.com/_licenses/unlicense.txt +1 -2
  124. data/vendor/choosealicense.com/_licenses/upl-1.0.txt +4 -5
  125. data/vendor/choosealicense.com/_licenses/vim.txt +111 -0
  126. data/vendor/choosealicense.com/_licenses/wtfpl.txt +0 -1
  127. data/vendor/choosealicense.com/_licenses/zlib.txt +4 -2
  128. metadata +77 -19
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe 'detect command' do
2
4
  let(:command) { ['bundle', 'exec', 'bin/licensee', 'detect'] }
3
5
  let(:arguments) { [] }
@@ -10,7 +12,7 @@ RSpec.describe 'detect command' do
10
12
  let(:stdout) { output[0] }
11
13
  let(:stderr) { output[1] }
12
14
  let(:status) { output[2] }
13
- let(:hash) { '46cdc03462b9af57968df67b450cc4372ac41f53' }
15
+ let(:hash) { license_hashes['mit'] }
14
16
  let(:expected) do
15
17
  {
16
18
  'License' => 'MIT',
@@ -39,7 +41,7 @@ RSpec.describe 'detect command' do
39
41
  let(:arguments) { args }
40
42
 
41
43
  it 'Returns a zero exit code' do
42
- expect(status.exitstatus).to eql(0)
44
+ expect(status.exitstatus).to be(0)
43
45
  end
44
46
 
45
47
  it 'returns the exected values' do
@@ -60,15 +62,17 @@ RSpec.describe 'detect command' do
60
62
  let(:expected) { JSON.parse fixture_contents('detect.json') }
61
63
 
62
64
  it 'Returns a zero exit code' do
63
- expect(status.exitstatus).to eql(0)
65
+ expect(status.exitstatus).to be(0)
64
66
  end
65
67
 
66
68
  it 'returns valid JSON' do
67
- expect { JSON.parse(stdout) }.to_not raise_error
69
+ expect { JSON.parse(stdout) }.not_to raise_error
68
70
  end
69
71
 
70
72
  it 'returns the expected output' do
71
- expect(JSON.parse(stdout)).to eql(expected)
73
+ msg = '`licensee detect --json` output did not match expectations. '.dup
74
+ msg << 'Run `script/dump-detect-json-fixture` and verify the output.'
75
+ expect(JSON.parse(stdout)).to eql(expected), msg
72
76
  end
73
77
  end
74
78
 
@@ -76,7 +80,7 @@ RSpec.describe 'detect command' do
76
80
  let(:command) { ['bundle', 'exec', 'bin/licensee'] }
77
81
 
78
82
  it 'Returns a zero exit code' do
79
- expect(status.exitstatus).to eql(0)
83
+ expect(status.exitstatus).to be(0)
80
84
  end
81
85
 
82
86
  it 'returns the exected values' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe 'license-path command' do
2
4
  let(:command) { ['bundle', 'exec', 'bin/licensee', 'license-path'] }
3
5
  let(:arguments) { [project_root] }
@@ -16,6 +18,6 @@ RSpec.describe 'license-path command' do
16
18
  end
17
19
 
18
20
  it 'Returns a zero exit code' do
19
- expect(status.exitstatus).to eql(0)
21
+ expect(status.exitstatus).to be(0)
20
22
  end
21
23
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe 'version command' do
2
4
  let(:command) { ['bundle', 'exec', 'bin/licensee', 'version'] }
3
5
  let(:arguments) { [] }
@@ -16,6 +18,6 @@ RSpec.describe 'version command' do
16
18
  end
17
19
 
18
20
  it 'Returns a zero exit code' do
19
- expect(status.exitstatus).to eql(0)
21
+ expect(status.exitstatus).to be(0)
20
22
  end
21
23
  end
@@ -1,15 +1,24 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ContentHelperTestHelper
2
4
  include Licensee::ContentHelper
3
- attr_accessor :content
5
+ attr_accessor :content, :data
4
6
 
5
- def initialize(content = nil)
7
+ def initialize(content = nil, data = {})
6
8
  @content = content
9
+ @data = data
10
+ end
11
+
12
+ def filename
13
+ @data[:filename]
7
14
  end
8
15
  end
9
16
 
10
17
  RSpec.describe Licensee::ContentHelper do
18
+ subject { ContentHelperTestHelper.new(content, filename: filename) }
19
+
11
20
  let(:content) do
12
- <<-LICENSE.freeze.gsub(/^\s*/, '')
21
+ <<-LICENSE.gsub(/^\s*/, '')
13
22
  # The MIT License
14
23
  =================
15
24
 
@@ -27,8 +36,10 @@ RSpec.describe Licensee::ContentHelper do
27
36
  -----------
28
37
  LICENSE
29
38
  end
30
- subject { ContentHelperTestHelper.new(content) }
39
+ let(:filename) { 'license.md' }
40
+
31
41
  let(:mit) { Licensee::License.find('mit') }
42
+ let(:normalized_content) { subject.content_normalized }
32
43
 
33
44
  it 'creates the wordset' do
34
45
  wordset = Set.new(
@@ -41,25 +52,25 @@ RSpec.describe Licensee::ContentHelper do
41
52
  end
42
53
 
43
54
  it 'knows the length' do
44
- expect(subject.length).to eql(135)
55
+ expect(subject.length).to be(135)
45
56
  end
46
57
 
47
58
  context 'a very long license' do
48
59
  let(:content) { 'license' * 1000 }
49
60
 
50
61
  it 'returns the max delta' do
51
- expect(subject.max_delta).to eql(140)
62
+ expect(subject.max_delta).to be(140)
52
63
  end
53
64
  end
54
65
 
55
66
  it 'knows the length delta' do
56
- expect(subject.length_delta(mit)).to eql(884)
57
- expect(subject.length_delta(subject)).to eql(0)
67
+ expect(subject.length_delta(mit)).to be(885)
68
+ expect(subject.length_delta(subject)).to be(0)
58
69
  end
59
70
 
60
71
  it 'knows the similarity' do
61
72
  expect(subject.similarity(mit)).to be_within(1).of(11)
62
- expect(subject.similarity(subject)).to eql(100.0)
73
+ expect(subject.similarity(subject)).to be(100.0)
63
74
  end
64
75
 
65
76
  it 'calculates the hash' do
@@ -68,75 +79,102 @@ RSpec.describe Licensee::ContentHelper do
68
79
  end
69
80
 
70
81
  it 'wraps' do
71
- content = Licensee::ContentHelper.wrap(mit.content, 40)
82
+ content = described_class.wrap(mit.content, 40)
72
83
  lines = content.split("\n")
73
84
  expect(lines.first.length).to be <= 40
74
85
  end
75
86
 
76
87
  it 'formats percents' do
77
- percent = Licensee::ContentHelper.format_percent(12.3456789)
88
+ percent = described_class.format_percent(12.3456789)
78
89
  expect(percent).to eql('12.35%')
79
90
  end
80
91
 
81
- context 'normalizing' do
82
- let(:normalized_content) { subject.content_normalized }
83
-
84
- it 'strips copyright' do
85
- expect(normalized_content).to_not match 'Copyright'
86
- expect(normalized_content).to_not match 'Ben Balter'
92
+ describe '#strip' do
93
+ {
94
+ version: "The MIT License\nVersion 1.0\nfoo",
95
+ hrs: "The MIT License\n=====\n-----\n*******\nfoo",
96
+ markdown_headings: "# The MIT License\n\nfoo",
97
+ whitespace: "The MIT License\n\n foo ",
98
+ all_rights_reserved: "Copyright 2016 Ben Balter\n\nfoo",
99
+ urls: "https://example.com\nfoo",
100
+ developed_by: "Developed By: Ben Balter\n\nFoo",
101
+ borders: '* Foo *',
102
+ title: "The MIT License\nfoo",
103
+ copyright: "The MIT License\nCopyright 2018 Ben Balter\nFoo",
104
+ end_of_terms: "Foo\nend of terms and conditions\nbar",
105
+ block_markup: '> Foo',
106
+ link_markup: '[Foo](http://exmaple.com)',
107
+ comment_markup: "/*\n* The MIT License\n* Foo\n*/",
108
+ copyright_title: "Copyright 2019 Ben Balter\nMIT License\nFoo"
109
+ }.each do |field, fixture|
110
+ context "#strip_#{field}" do
111
+ let(:content) { fixture }
112
+
113
+ it "strips #{field}" do
114
+ expect(normalized_content).to eql('foo')
115
+ end
116
+ end
87
117
  end
88
118
 
89
- it 'downcases' do
90
- expect(normalized_content).to_not match 'The'
91
- expect(normalized_content).to match 'the'
119
+ context 'span markup' do
120
+ let(:content) { '_foo_ *foo* **foo** ~foo~' }
121
+
122
+ it 'strips span markup' do
123
+ expect(normalized_content).to eql('foo foo foo foo')
124
+ end
92
125
  end
93
126
 
94
- it 'strips HRs' do
95
- expect(normalized_content).to_not match '---'
96
- expect(normalized_content).to_not match '==='
97
- expect(normalized_content).to_not include '***'
98
- expect(normalized_content).to_not include '* *'
127
+ context 'HTML' do
128
+ let(:content) { '<ul><li>foo</li></ul>' }
129
+ let(:filename) { 'license.html' }
130
+
131
+ it 'strips HTML' do
132
+ expect(normalized_content).to eql('- foo')
133
+ end
99
134
  end
135
+ end
100
136
 
101
- it 'strips formatting from the MPL' do
102
- license = Licensee::License.find('mpl-2.0')
103
- expect(license.content_normalized).to_not include('* *')
137
+ context 'integration fixture' do
138
+ it 'strips copyright' do
139
+ expect(normalized_content).not_to match 'Copyright'
140
+ expect(normalized_content).not_to match 'Ben Balter'
104
141
  end
105
142
 
106
- it 'normalizes http: to https:' do
107
- license = Licensee::License.find('mpl-2.0')
108
- expect(license.content).to include('http:')
109
- expect(license.content_normalized).to_not include('http:')
143
+ it 'downcases' do
144
+ expect(normalized_content).not_to match 'The'
145
+ expect(normalized_content).to match 'the'
110
146
  end
111
147
 
112
- it 'wraps' do
113
- lines = mit.content_normalized(wrap: 40).split("\n")
114
- expect(lines.first.length).to be <= 40
148
+ it 'strips HRs' do
149
+ expect(normalized_content).not_to match '---'
150
+ expect(normalized_content).not_to match '==='
151
+ expect(normalized_content).not_to include '***'
152
+ expect(normalized_content).not_to include '* *'
115
153
  end
116
154
 
117
155
  it 'squeezes whitespace' do
118
- expect(normalized_content).to_not match ' '
156
+ expect(normalized_content).not_to match ' '
119
157
  end
120
158
 
121
159
  it 'strips whitespace' do
122
- expect(normalized_content).to_not match(/\n/)
123
- expect(normalized_content).to_not match(/\t/)
160
+ expect(normalized_content).not_to match(/\n/)
161
+ expect(normalized_content).not_to match(/\t/)
124
162
  end
125
163
 
126
164
  it 'strips markdown headings' do
127
- expect(normalized_content).to_not match('#')
165
+ expect(normalized_content).not_to match('#')
128
166
  end
129
167
 
130
168
  it 'strips all rights reserved' do
131
- expect(normalized_content).to_not match(/all rights reserved/i)
169
+ expect(normalized_content).not_to match(/all rights reserved/i)
132
170
  end
133
171
 
134
172
  it 'strips markup' do
135
- expect(normalized_content).to_not match(/[*=_-]+/)
173
+ expect(normalized_content).not_to match(/[*=_-]+/)
136
174
  end
137
175
 
138
176
  it 'normalizes quotes' do
139
- expect(normalized_content).to_not match("'as is'")
177
+ expect(normalized_content).not_to match("'as is'")
140
178
  end
141
179
 
142
180
  it 'preserves possessives' do
@@ -148,55 +186,120 @@ RSpec.describe Licensee::ContentHelper do
148
186
  expect(normalized_content).to match('"software"')
149
187
  end
150
188
 
189
+ it 'strips the title' do
190
+ expect(normalized_content).not_to match('MIT')
191
+ end
192
+
193
+ it 'normalize the content' do
194
+ expected = 'the made up license. this license provided "as is". '.dup
195
+ expected << "please respect the contributors' wishes when implementing "
196
+ expected << "the license's \"software\"."
197
+ expect(normalized_content).to eql(expected)
198
+ end
199
+ end
200
+
201
+ context 'normalizing' do
202
+ context 'https' do
203
+ let(:content) { 'http://example.com' }
204
+
205
+ it 'normalized URL protocals' do
206
+ expect(subject.content_normalized).to eql('https://example.com')
207
+ end
208
+ end
209
+
210
+ context 'ampersands' do
211
+ let(:content) { 'Foo & Bar' }
212
+
213
+ it 'normalized ampersands' do
214
+ expect(subject.content_normalized).to eql('foo and bar')
215
+ end
216
+ end
217
+
218
+ context 'lists' do
219
+ let(:content) { "1. Foo\n * Bar" }
220
+
221
+ it 'normalizes lists' do
222
+ expect(subject.content_normalized).to eql('- foo - bar')
223
+ end
224
+ end
225
+
226
+ context 'dashes' do
227
+ let(:content) { 'Foo-Bar—–baz-buzz' }
228
+
229
+ it 'normalizes dashes' do
230
+ expect(subject.content_normalized).to eql('foo-bar-baz-buzz')
231
+ end
232
+ end
233
+
234
+ context 'quotes' do
235
+ let(:content) { "`a` 'b' \"c\" ‘d’ “e”" }
236
+
237
+ it 'normalizes quotes' do
238
+ expect(subject.content_normalized).to eql('"a" "b" "c" "d" "e"')
239
+ end
240
+ end
241
+
242
+ it 'strips formatting from the MPL' do
243
+ license = Licensee::License.find('mpl-2.0')
244
+ expect(license.content_normalized).not_to include('* *')
245
+ end
246
+
247
+ it 'normalizes http: to https:' do
248
+ license = Licensee::License.find('mpl-2.0')
249
+ expect(license.content).to include('http:')
250
+ expect(license.content_normalized).not_to include('http:')
251
+ end
252
+
253
+ it 'wraps' do
254
+ lines = mit.content_normalized(wrap: 40).split("\n")
255
+ expect(lines.first.length).to be <= 40
256
+ end
257
+
258
+ context 'spelling' do
259
+ let(:content) { 'licence' }
260
+
261
+ it 'normalizes' do
262
+ expect(subject.content_normalized).to eql('license')
263
+ end
264
+ end
265
+
151
266
  Licensee::License.all(hidden: true).each do |license|
152
267
  context license.name do
153
268
  let(:stripped_content) { subject.content_without_title_and_version }
154
269
 
155
270
  it 'strips the title' do
156
- regex = Licensee::ContentHelper::ALT_TITLE_REGEX[license.key]
157
- regex ||= /\A#{license.name_without_version}/i
158
- expect(license.content_normalized).to_not match(regex)
159
- expect(stripped_content).to_not match(regex)
271
+ regex = /\A#{license.name_without_version}/i
272
+ expect(stripped_content).not_to match(regex)
273
+ expect(license.content_normalized).not_to match(regex)
160
274
  end
161
275
 
162
276
  it 'strips the version' do
163
- expect(license.content_normalized).to_not match(/\Aversion/i)
164
- expect(stripped_content).to_not match(/\Aversion/i)
277
+ expect(license.content_normalized).not_to match(/\Aversion/i)
278
+ expect(stripped_content).not_to match(/\Aversion/i)
165
279
  end
166
280
 
167
281
  it 'strips all rights reserved' do
168
282
  regex = /all rights reserved/i
169
- expect(license.content_normalized).to_not match(regex)
283
+ expect(license.content_normalized).not_to match(regex)
170
284
  end
171
285
 
172
286
  it 'strips the copyright' do
173
- expect(license.content_normalized).to_not match(/\Acopyright/i)
287
+ expect(license.content_normalized).not_to match(/\Acopyright/i)
174
288
  end
175
289
 
176
290
  it 'strips the implementation instructions' do
177
291
  end_terms_regex = /END OF TERMS AND CONDITIONS/i
178
- expect(license.content_normalized).to_not match(end_terms_regex)
179
- expect(license.content_normalized).to_not match(/How to apply/i)
292
+ expect(license.content_normalized).not_to match(end_terms_regex)
293
+ expect(license.content_normalized).not_to match(/How to apply/i)
180
294
  end
181
295
  end
182
296
  end
183
297
 
184
- it 'strips the title' do
185
- expect(normalized_content).to_not match('MIT')
186
- end
187
-
188
- it 'normalize the content' do
189
- expected = 'the made up license. this license provided "as is". '
190
- expected << "please respect the contributors' wishes when implementing "
191
- expected << "the license's \"software\"."
192
- expect(normalized_content).to eql(expected)
193
- end
194
-
195
298
  context 'a title in parenthesis' do
196
299
  let(:content) { "(The MIT License)\n\nfoo" }
197
300
 
198
301
  it 'strips the title' do
199
- expect(normalized_content).to_not match('MIT')
302
+ expect(normalized_content).not_to match('MIT')
200
303
  expect(normalized_content).to eql('foo')
201
304
  end
202
305
  end
@@ -205,7 +308,7 @@ RSpec.describe Licensee::ContentHelper do
205
308
  let(:content) { "Copyright 2016 Ben Balter\nCopyright 2017 Bob\nFoo" }
206
309
 
207
310
  it 'strips multiple copyrights' do
208
- expect(normalized_content).to_not match('Ben')
311
+ expect(normalized_content).not_to match('Ben')
209
312
  expect(normalized_content).to eql('foo')
210
313
  end
211
314
  end
@@ -259,7 +362,7 @@ RSpec.describe Licensee::ContentHelper do
259
362
  let(:text) { 'gpl-3 0' }
260
363
 
261
364
  it 'escapes' do
262
- expect(text).to_not match(described_class.title_regex)
365
+ expect(text).not_to match(described_class.title_regex)
263
366
  end
264
367
  end
265
368
 
@@ -269,10 +372,24 @@ RSpec.describe Licensee::ContentHelper do
269
372
  end
270
373
 
271
374
  it 'matches' do
272
- expect(text).to_not match(described_class.title_regex)
375
+ expect(text).not_to match(described_class.title_regex)
273
376
  end
274
377
  end
275
378
  end
276
379
  end
277
380
  end
381
+
382
+ context 'metaprogramming' do
383
+ it 'raises on invalid normalization' do
384
+ expect { subject.send(:normalize, :foo) }.to raise_error(ArgumentError)
385
+ end
386
+
387
+ it 'raises on invalid strip' do
388
+ expect { subject.send(:strip, :foo) }.to raise_error(ArgumentError)
389
+ end
390
+
391
+ it 'backwards compatibalizes regexes' do
392
+ expect(described_class::WHITESPACE_REGEX).to eql(/\s+/)
393
+ end
394
+ end
278
395
  end