spec/licensee/content_helper_spec.rb in licensee-9.7.0 vs spec/licensee/content_helper_spec.rb in licensee-9.8.0

- old
+ new

@@ -19,22 +19,31 @@ All rights reserved. The made * * * * up license. + + This license provided 'as is'. Please respect the contributors' wishes when + implementing the license's "software". ----------- LICENSE end subject { ContentHelperTestHelper.new(content) } let(:mit) { Licensee::License.find('mit') } it 'creates the wordset' do - expect(subject.wordset).to eql(Set.new(%w[the made up license])) + wordset = Set.new( + %w[ + the made up license this provided as is please respect + contributors' wishes when implementing license's software + ] + ) + expect(subject.wordset).to eql(wordset) end it 'knows the length' do - expect(subject.length).to eql(20) + expect(subject.length).to eql(135) end context 'a very long license' do let(:content) { 'license' * 1000 } @@ -42,21 +51,21 @@ expect(subject.max_delta).to eql(140) end end it 'knows the length delta' do - expect(subject.length_delta(mit)).to eql(999) + expect(subject.length_delta(mit)).to eql(884) expect(subject.length_delta(subject)).to eql(0) end it 'knows the similarity' do - expect(subject.similarity(mit)).to be_within(1).of(2) + expect(subject.similarity(mit)).to be_within(1).of(11) expect(subject.similarity(subject)).to eql(100.0) end it 'calculates the hash' do - content_hash = '3c59634b9fae4396a76a978f3f6aa718ed790a9a' + content_hash = '916b978940ecf8070c96bd3aca9321768e7f4901' expect(subject.content_hash).to eql(content_hash) end it 'wraps' do content = Licensee::ContentHelper.wrap(mit.content, 40) @@ -118,10 +127,23 @@ it 'strips markup' do expect(normalized_content).to_not match(/[*=_-]+/) end + it 'normalizes quotes' do + expect(normalized_content).to_not match("'as is'") + end + + it 'preserves possessives' do + expect(normalized_content).to match("contributors'") + expect(normalized_content).to match("license's") + end + + it 'preserves double quotes' do + expect(normalized_content).to match('"software"') + end + Licensee::License.all(hidden: true).each do |license| context license.name do let(:stripped_content) { subject.content_without_title_and_version } it 'strips the title' do @@ -156,10 +178,13 @@ 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.' + expected = 'the made up license. this license provided "as is". ' + expected << "please respect the contributors' wishes when implementing " + expected << "the license's \"software\"." + expect(normalized_content).to eql(expected) end context 'a title in parenthesis' do let(:content) { "(The MIT License)\n\nfoo" }