From 286357a54c87b3adaf7ae5c5314275626f31b977 Mon Sep 17 00:00:00 2001 From: Mike Linksvayer Date: Sun, 8 Oct 2017 20:31:34 -0700 Subject: [PATCH] loosen fields matching regex, check no supported fields missed --- spec/license_fields_spec.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/license_fields_spec.rb b/spec/license_fields_spec.rb index 1c0d409..b89b9e7 100644 --- a/spec/license_fields_spec.rb +++ b/spec/license_fields_spec.rb @@ -5,11 +5,16 @@ require 'spec_helper' describe 'license fillable fields' do licenses.each do |license| context "The #{license['title']} license" do + matches = license['content'].scan(/(\A|\W)\[([a-z]+)\]/).map {|row| row[1]} + extra_fields = matches.flatten - (fields.map { |f| f['name'] }) it 'should only contain supported fillable fields' do - matches = license['content'].scan(/\s+\[([a-z]+)\]\s+/) - extra_fields = matches.flatten - (fields.map { |f| f['name'] }) expect(extra_fields).to be_empty end + it 'does not overlook supported fillable fields' do + matches_generous = license['content'].scan(/\[([a-z]+)\]/) + extra_fields_generous = matches_generous.flatten - (fields.map { |f| f['name'] }) + expect(matches_generous.flatten - extra_fields_generous).to eq matches + end end end end