spec/licensee/content_helper_spec.rb in licensee-9.14.1 vs spec/licensee/content_helper_spec.rb in licensee-9.15.0

- old
+ new

@@ -10,14 +10,18 @@ end def filename @data[:filename] end + + def spdx_id + @data[:spdx_id] + end end RSpec.describe Licensee::ContentHelper do - subject { ContentHelperTestHelper.new(content, filename: filename) } + subject { ContentHelperTestHelper.new(content, filename: filename, spdx_id: spdx_id) } let(:content) do <<-LICENSE.gsub(/^\s*/, '') # The MIT License ================= @@ -35,18 +39,19 @@ implementing the license's "software". ----------- LICENSE end let(:filename) { 'license.md' } + let(:spdx_id) { 'MIT' } let(:mit) { Licensee::License.find('mit') } let(:normalized_content) { subject.content_normalized } it 'creates the wordset' do wordset = Set.new( %w[ - the made up license this provided as is please respect + the made up license this provided as is' please respect contributors' wishes when implementing license's software ] ) expect(subject.wordset).to eql(wordset) end @@ -59,16 +64,16 @@ expect(subject.length_delta(mit)).to be(885) expect(subject.length_delta(subject)).to be(0) end it 'knows the similarity' do - expect(subject.similarity(mit)).to be_within(1).of(6) - expect(subject.similarity(subject)).to be(100.0) + expect(mit.similarity(subject)).to be_within(1).of(4) + expect(mit.similarity(mit)).to be(100.0) end it 'calculates the hash' do - content_hash = '916b978940ecf8070c96bd3aca9321768e7f4901' + content_hash = '9b4bed43726cf39e17b11c2942f37be232f5709a' expect(subject.content_hash).to eql(content_hash) end it 'wraps' do content = described_class.wrap(mit.content, 40) @@ -167,30 +172,26 @@ it 'strips markup' do expect(normalized_content).not_to match(/[*=_-]+/) end it 'normalizes quotes' do - expect(normalized_content).not_to match("'as is'") + expect(normalized_content).not_to 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 - it 'strips the title' do expect(normalized_content).not_to match('MIT') end it 'normalize the content' do - expected = 'the made up license. this license provided "as is". '.dup + expected = +"the made up license. this license provided 'as is'. " expected << "please respect the contributors' wishes when implementing " - expected << "the license's \"software\"." + expected << "the license's 'software'." expect(normalized_content).to eql(expected) end end context 'normalizing' do @@ -228,10 +229,10 @@ context 'quotes' do let(:content) { "`a` 'b' \"c\" ā€˜dā€™ ā€œeā€" } it 'normalizes quotes' do - expect(subject.content_normalized).to eql('"a" "b" "c" "d" "e"') + expect(subject.content_normalized).to eql("'a' 'b' 'c' 'd' 'e'") end end it 'strips formatting from the MPL' do license = Licensee::License.find('mpl-2.0')