mirror of
https://github.com/github/choosealicense.com
synced 2024-12-22 04:40:09 +01:00
fix spec
This commit is contained in:
parent
853f4c97b2
commit
415ac8a174
13
Rakefile
13
Rakefile
@ -12,3 +12,16 @@ task :test do
|
||||
HTML::Proofer.new("./_site", :check_html => true).run
|
||||
Rake::Task["spec"].invoke
|
||||
end
|
||||
|
||||
task :approved_licenses do
|
||||
require './spec/spec_helper'
|
||||
approved = approved_licenses
|
||||
approved.select! { |l| spdx_ids.include?(l) }
|
||||
puts "#{approved.count} approved licenses:"
|
||||
puts approved.join(", ")
|
||||
puts "\n"
|
||||
|
||||
potential = approved - licenses.map { |l| l["id"] }
|
||||
puts "#{potential.count} potential additions:"
|
||||
puts potential.join(", ")
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ licenses.each do |license|
|
||||
|
||||
describe "The #{license["title"]} license" do
|
||||
|
||||
let(:id) { license["id"] }
|
||||
let(:id) { license["id"] }
|
||||
|
||||
it "has an SPDX ID" do
|
||||
expect(spdx_ids).to include(id)
|
||||
@ -18,14 +18,16 @@ licenses.each do |license|
|
||||
expect(spdx[1]["name"].gsub(/ only$/,"")).to eql(license["title"])
|
||||
end
|
||||
|
||||
it "should be approved by OSI or FSF or OD" do
|
||||
osi = osi_approved?(id)
|
||||
fsf = fsf_approved?(id)
|
||||
od = od_approved?(id)
|
||||
context "industry approval" do
|
||||
|
||||
approved = osi || fsf || od
|
||||
msg = "The license must be approved by OSI, FSF, or OD. See https://git.io/vzCTV."
|
||||
expect(approved).to eql(true), msg
|
||||
# FSF approved the clear BSD, but doesn't use it's SPDX ID or Name
|
||||
if license["id"] == "bsd-3-clause-clear"
|
||||
let(:id) { "clearbsd" }
|
||||
end
|
||||
|
||||
it "should be approved by OSI or FSF or OD" do
|
||||
expect(approved_licenses).to include(id), "See https://git.io/vzCTV."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -64,10 +64,15 @@ def find_spdx(license)
|
||||
spdx_list.find { |name, properties| name.downcase == license }
|
||||
end
|
||||
|
||||
def osi_approved?(id)
|
||||
spdx = find_spdx(id)
|
||||
return false unless spdx
|
||||
spdx[1]["osiApproved"]
|
||||
def osi_approved_licenses
|
||||
$osi_approved_licenses ||= begin
|
||||
licenses = {}
|
||||
list = spdx_list.select { |id, meta| meta["osiApproved"] }
|
||||
list.each do |id, meta|
|
||||
licenses[id.downcase] = meta["name"]
|
||||
end
|
||||
licenses
|
||||
end
|
||||
end
|
||||
|
||||
def fsf_approved_licenses
|
||||
@ -87,10 +92,6 @@ def fsf_approved_licenses
|
||||
end
|
||||
end
|
||||
|
||||
def fsf_approved?(id)
|
||||
fsf_approved_licenses.keys.include?(id)
|
||||
end
|
||||
|
||||
def od_approved_licenses
|
||||
$od_approved_licenses ||= begin
|
||||
url = "http://licenses.opendefinition.org/licenses/groups/od.json"
|
||||
@ -104,6 +105,6 @@ def od_approved_licenses
|
||||
end
|
||||
end
|
||||
|
||||
def od_approved?(id)
|
||||
od_approved_licenses.keys.include?(id)
|
||||
def approved_licenses
|
||||
(osi_approved_licenses.keys + fsf_approved_licenses.keys + od_approved_licenses.keys).flatten.uniq.sort
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user