diff --git a/spec/license_bom_spec.rb b/spec/license_bom_spec.rb index c2a82e4..883d68e 100644 --- a/spec/license_bom_spec.rb +++ b/spec/license_bom_spec.rb @@ -1,16 +1,13 @@ require 'spec_helper' -describe "license file" do - - bom = "\xEF\xBB\xBF".each_byte.to_a - - files = Dir["_licenses/*.txt"] - - files.each do |fn| - first3 = File.open(fn) {|f| f.read(3)} - - it "#{fn} should not have a byte order mark" do - expect(first3.each_byte.to_a).not_to eq(bom) +describe "byte order marks" do + Dir["#{licenses_path}/*.txt"].each do |file| + context "the #{File.basename(file, ".txt")} license" do + it "does not begin with a byte order mark" do + bom = !!(File.open(file).read =~ /\A\xEF\xBB\xBF/) + msg = "License file begins with a Byte Order Mark. See http://stackoverflow.com/a/1068700." + expect(bom).to eql(false), msg + end end end end diff --git a/spec/license_spec.rb b/spec/license_spec.rb index 4cfb741..07d944c 100644 --- a/spec/license_spec.rb +++ b/spec/license_spec.rb @@ -2,6 +2,10 @@ require 'spec_helper' describe "licenses" do + it "matches the number of files in the _licenses folder" do + expect(licenses.count).to eql(Dir["#{licenses_path}/*.txt"].count) + end + licenses.each do |license| context "The #{license["title"]} license" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6341223..64f8cb0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,6 +12,10 @@ def source File.expand_path("../", File.dirname(__FILE__)) end +def licenses_path + File.expand_path "_licenses", source +end + def config config = Jekyll::Configuration.new.read_config_file config_file config = Jekyll::Utils.deep_merge_hashes(config, {:source => source})