From df0fd9213fde40b4e4bab18b52ab30f310a750b7 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Sat, 22 Aug 2015 15:42:12 -0400 Subject: [PATCH] add rules spec --- _licenses/cc0-1.0.txt | 2 +- spec/license_meta_spec.rb | 2 +- spec/license_rules_spec.rb | 24 ++++++++++++++++++++++++ spec/license_spec.rb | 16 ---------------- 4 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 spec/license_rules_spec.rb diff --git a/_licenses/cc0-1.0.txt b/_licenses/cc0-1.0.txt index 9bf170a..8a92a85 100644 --- a/_licenses/cc0-1.0.txt +++ b/_licenses/cc0-1.0.txt @@ -20,7 +20,7 @@ permitted: - modifications - distribution - private-use - + forbidden: - no-liability diff --git a/spec/license_meta_spec.rb b/spec/license_meta_spec.rb index 6635de2..796b7eb 100644 --- a/spec/license_meta_spec.rb +++ b/spec/license_meta_spec.rb @@ -16,7 +16,7 @@ licenses.each do |license| missing = required - raw_fields.keys expect(missing).to be_empty end - + if license["category"] it "should contain the required license variant fields" do missing = ["category", "tab-slug"] - license.keys diff --git a/spec/license_rules_spec.rb b/spec/license_rules_spec.rb new file mode 100644 index 0000000..5049bea --- /dev/null +++ b/spec/license_rules_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper' + +licenses.each do |license| + + groups = rules.keys + + describe "The #{license["title"]} license" do + groups.each do |group| + + 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 + + it "should only contain valid tags" do + extra = license[group] - valid_tags + expect(extra).to be_empty + end + end + end + end +end diff --git a/spec/license_spec.rb b/spec/license_spec.rb index 750a78b..db20cde 100644 --- a/spec/license_spec.rb +++ b/spec/license_spec.rb @@ -31,21 +31,5 @@ licenses.each do |license| end end end - - ["permitted", "required", "forbidden"].each do |group| - describe "#{group} properties" do - it "should list the properties" do - expect(license[group]).to_not be_nil - end - - license[group].to_a.each do |tag| - describe "#{tag} tag" do - it "should be a valid tag" do - expect(rule?(tag,group)).to be(true) - end - end - end - end - end end end