summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2019-10-22 16:24:18 -0600
committermo khan <mo.khan@gmail.com>2019-10-23 11:07:42 -0600
commit9038552abe7c4b0ebca9795121f9d48564492b3c (patch)
tree65c855c8803b8ccc13446ddf47f2cd444ffca5be /spec
parentef5e5ec0b635d3968a6699b8d6711dd75f568b7d (diff)
Parse spdx id from known sources
Diffstat (limited to 'spec')
-rw-r--r--spec/license/management/repository_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/license/management/repository_spec.rb b/spec/license/management/repository_spec.rb
new file mode 100644
index 0000000..dbc0a22
--- /dev/null
+++ b/spec/license/management/repository_spec.rb
@@ -0,0 +1,27 @@
+RSpec.describe License::Management::Repository do
+ describe "#item_for" do
+ let(:spdx_licenses) { JSON.parse(IO.read('spdx-licenses.json'))['licenses'] }
+
+ context "when mapping a license that refers to opensource.org" do
+ it 'parses the SPDX id from the url' do
+ spdx_licenses.each do |license|
+ spdx_id = license['licenseId']
+ url = "https://opensource.org/licenses/#{spdx_id}"
+ license = LicenseFinder::License.new(short_name: url, matcher: LicenseFinder::License::NoneMatcher.new, url: url)
+ expect(subject.item_for(license)['id']).to eql(spdx_id)
+ end
+ end
+ end
+
+ context "when mapping a license that refers to nuget.org" do
+ it 'parses the SPDX id from the url' do
+ spdx_licenses.each do |license|
+ spdx_id = license['licenseId']
+ url = "https://licenses.nuget.org/#{spdx_id}"
+ license = LicenseFinder::License.new(short_name: url, matcher: LicenseFinder::License::NoneMatcher.new, url: url)
+ expect(subject.item_for(license)['id']).to eql(spdx_id)
+ end
+ end
+ end
+ end
+end