diff --git a/spec/license_category_spec.rb b/spec/license_category_spec.rb index 423bb14..e90f6f4 100644 --- a/spec/license_category_spec.rb +++ b/spec/license_category_spec.rb @@ -1,29 +1,31 @@ require 'spec_helper' -families.each do |family| - describe "the #{family} family" do - family_licenses = licenses.select { |l| l["family"] == family } - primary = family_licenses.select { |l| l["variant"] == false } - variants = family_licenses.select { |l| l["variant"] == true } +describe "license categories" do + families.each do |family| + context "the #{family} family" do + family_licenses = licenses.select { |l| l["family"] == family } + primary = family_licenses.select { |l| l["variant"] == false } + variants = family_licenses.select { |l| l["variant"] == true } - it "should only have one primary license" do - expect(primary.count).to eql(1) - end + it "should only have one primary license" do + expect(primary.count).to eql(1) + end - it "all other licenses should be variants" do - expected = family_licenses.count - 1 - expect(variants.count).to eql(expected) - end + it "all other licenses should be variants" do + expected = family_licenses.count - 1 + expect(variants.count).to eql(expected) + end - family_licenses.each do |license| - describe "the #{license["title"]} license" do - it "should have a unique slug" do - dupes = family_licenses.select { |l| l["tab-slug"] == license["tab-slug"] }.count - expect(dupes).to eql(1) - end + family_licenses.each do |license| + context "the #{license["title"]} license" do + it "should have a unique slug" do + dupes = family_licenses.select { |l| l["tab-slug"] == license["tab-slug"] }.count + expect(dupes).to eql(1) + end - it "should have a valid tab-slug" do - expect(license["tab-slug"]).to match(/[a-z0-9_]/) + it "should have a valid tab-slug" do + expect(license["tab-slug"]).to match(/[a-z0-9_]/) + end end end end diff --git a/spec/license_fields_spec.rb b/spec/license_fields_spec.rb index 5ea79d6..ef2ae6b 100644 --- a/spec/license_fields_spec.rb +++ b/spec/license_fields_spec.rb @@ -1,11 +1,13 @@ require 'spec_helper' -licenses.each do |license| - describe "The #{license["title"]} license" do - it "should only contain supported fields" do - matches = license["content"].scan /\[([a-z]+)\]/ - extra_fields = matches.flatten - fields.map { |f| f["name"] } - expect(extra_fields).to be_empty +describe "license fillable fields" do + licenses.each do |license| + context "The #{license["title"]} license" do + it "should only contain supported fillable fields" do + matches = license["content"].scan(/\[([a-z]+)\]/) + extra_fields = matches.flatten - fields.map { |f| f["name"] } + expect(extra_fields).to be_empty + end end end end diff --git a/spec/license_meta_spec.rb b/spec/license_meta_spec.rb index 3649cc8..e0f2b8e 100644 --- a/spec/license_meta_spec.rb +++ b/spec/license_meta_spec.rb @@ -1,31 +1,33 @@ require 'spec_helper' -licenses.each do |license| +describe "license meta" do + licenses.each do |license| - # Manually load the raw license so we don't get thed defaults - raw_fields = SafeYAML.load_file("_licenses/#{license["id"]}.txt") + # Manually load the raw license so we don't get thed defaults + raw_fields = SafeYAML.load_file("_licenses/#{license["id"]}.txt") - describe "The #{license["title"]} license" do - it "should only contain supported meta fields" do - extra_fields = raw_fields.keys - meta.map { |m| m["name"] } - expect(extra_fields).to be_empty - end + context "The #{license["title"]} license" do + it "should only contain supported meta fields" do + extra_fields = raw_fields.keys - meta.map { |m| m["name"] } + expect(extra_fields).to be_empty + end - it "should contain all required meta fields" do - required = meta.select { |m| m["required"] }.map { |m| m["name"] } - missing = required - raw_fields.keys - expect(missing).to be_empty - end - - if license["family"] - it "should contain the required license variant fields" do - missing = ["family", "tab-slug"] - license.keys + it "should contain all required meta fields" do + required = meta.select { |m| m["required"] }.map { |m| m["name"] } + missing = required - raw_fields.keys expect(missing).to be_empty end - else - it "should not contain license family specific fields" do - extra = ["variant", "family", "tab-slug"].select{ |f| raw_fields.keys.include?(f) } - expect(extra).to be_empty + + if license["family"] + it "should contain the required license variant fields" do + missing = ["family", "tab-slug"] - license.keys + expect(missing).to be_empty + end + else + it "should not contain license family specific fields" do + extra = ["variant", "family", "tab-slug"].select{ |f| raw_fields.keys.include?(f) } + expect(extra).to be_empty + end end end end diff --git a/spec/license_rules_spec.rb b/spec/license_rules_spec.rb index 5049bea..c3093da 100644 --- a/spec/license_rules_spec.rb +++ b/spec/license_rules_spec.rb @@ -1,22 +1,24 @@ require 'spec_helper' -licenses.each do |license| +describe "license rules" do + licenses.each do |license| - groups = rules.keys + groups = rules.keys - describe "The #{license["title"]} license" do - groups.each do |group| + context "The #{license["title"]} license" do + groups.each do |group| - valid_tags = rules[group].map { |r| r["tag"] } + valid_tags = rules[group].map { |r| r["tag"] } - describe "the #{group} group" do - it "should exist" do - expect(license[group]).to_not be_nil - end + context "the #{group} group" do + it "should exist" do + expect(license[group]).to_not be_nil + end - it "should only contain valid tags" do - extra = license[group] - valid_tags - expect(extra).to be_empty + it "should only contain valid tags" do + extra = license[group] - valid_tags + expect(extra).to be_empty + end end end end diff --git a/spec/license_spec.rb b/spec/license_spec.rb index 6bf43b0..e60cb64 100644 --- a/spec/license_spec.rb +++ b/spec/license_spec.rb @@ -1,26 +1,28 @@ require 'spec_helper' -licenses.each do |license| +describe "licenses" do + licenses.each do |license| - # "No license" isn't really a license, so no need to test - next if license["id"] == "no-license" + # "No license" isn't really a license, so no need to test + next if license["id"] == "no-license" - describe "The #{license["title"]} license" do + context "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) - end + it "has an SPDX ID" do + expect(spdx_ids).to include(id) + end - it "uses its SPDX name" do - spdx = find_spdx(id) - expect(spdx[1]["name"].gsub(/ only$/,"")).to eql(license["title"]) - end + it "uses its SPDX name" do + spdx = find_spdx(id) + expect(spdx[1]["name"].gsub(/ only$/,"")).to eql(license["title"]) + end - context "industry approval" do - it "should be approved by OSI or FSF or OD" do - expect(approved_licenses).to include(id), "See https://git.io/vzCTV." + context "industry approval" do + 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