1
0
mirror of https://github.com/github/choosealicense.com synced 2024-07-01 16:13:02 +02:00

loosen fields matching regex, check no supported fields missed

This commit is contained in:
Mike Linksvayer 2017-10-08 20:31:34 -07:00
parent c02073ebdb
commit 286357a54c

View File

@ -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