spec/licensee/content_helper_spec.rb in licensee-8.7.0 vs spec/licensee/content_helper_spec.rb in licensee-8.8.0

- old
+ new

@@ -1,10 +1,12 @@ class ContentHelperTestHelper include Licensee::ContentHelper attr_accessor :content DEFAULT_CONTENT = <<-EOS.freeze +The MIT License + Copyright 2016 Ben Balter The made up license. ----------- @@ -30,16 +32,16 @@ it 'knows the max delta' do expect(subject.max_delta).to eql(1) end it 'knows the length delta' do - expect(subject.length_delta(mit)).to eql(1012) + expect(subject.length_delta(mit)).to eql(1000) expect(subject.length_delta(subject)).to eql(0) end it 'knows the similarity' do - expect(subject.similarity(mit)).to be_within(1).of(4) + expect(subject.similarity(mit)).to be_within(1).of(2) expect(subject.similarity(subject)).to eql(100.0) end it 'calculates the hash' do expect(subject.hash).to eql('3c59634b9fae4396a76a978f3f6aa718ed790a9a') @@ -66,9 +68,36 @@ expect(normalized_content).to_not match ' ' end it 'strips whitespace' do expect(normalized_content).to_not match(/\n/) + end + + Licensee::License.all(hidden: true).each do |license| + context license.name do + it 'strips the title' do + regex = /\A#{license.name_without_version}/i + expect(license.content_normalized).to_not match(regex) + end + + it 'strips the version' do + expect(license.content_normalized).to_not match(/\Aversion/i) + end + + it 'strips the copyright' do + expect(license.content_normalized).to_not match(/\Acopyright/i) + end + + it 'strips the implementation instructions' do + end_terms_regex = /END OF TERMS AND CONDITIONS/i + expect(license.content_normalized).to_not match(end_terms_regex) + expect(license.content_normalized).to_not match(/How to apply/i) + end + end + end + + it 'strips the title' do + expect(normalized_content).to_not match('MIT') end it 'normalize the content' do expect(normalized_content).to eql 'the made up license.' end