spec/licensee/content_helper_spec.rb in licensee-9.11.0 vs spec/licensee/content_helper_spec.rb in licensee-9.12.0

- old
+ new

@@ -1,17 +1,24 @@ +# frozen_string_literal: true + class ContentHelperTestHelper include Licensee::ContentHelper - attr_accessor :content + attr_accessor :content, :data - def initialize(content = nil) + def initialize(content = nil, data = {}) @content = content + @data = data end + + def filename + @data[:filename] + end end RSpec.describe Licensee::ContentHelper do let(:content) do - <<-LICENSE.freeze.gsub(/^\s*/, '') + <<-LICENSE.gsub(/^\s*/, '') # The MIT License ================= Copyright 2016 Ben Balter ************************* @@ -25,11 +32,12 @@ This license provided 'as is'. Please respect the contributors' wishes when implementing the license's "software". ----------- LICENSE end - subject { ContentHelperTestHelper.new(content) } + let(:filename) { 'license.md' } + subject { ContentHelperTestHelper.new(content, filename: filename) } let(:mit) { Licensee::License.find('mit') } let(:normalized_content) { subject.content_normalized } it 'creates the wordset' do wordset = Set.new( @@ -110,10 +118,19 @@ it 'strips span markup' do expect(normalized_content).to eql('foo foo foo foo') end end + + context 'HTML' do + let(:content) { '<ul><li>foo</li></ul>' } + let(:filename) { 'license.html' } + + it 'strips HTML' do + expect(normalized_content).to eql('- foo') + end + end end context 'integration fixture' do it 'strips copyright' do expect(normalized_content).to_not match 'Copyright' @@ -169,10 +186,10 @@ it 'strips the title' do expect(normalized_content).to_not match('MIT') end it 'normalize the content' do - expected = 'the made up license. this license provided "as is". ' + expected = 'the made up license. this license provided "as is". '.dup expected << "please respect the contributors' wishes when implementing " expected << "the license's \"software\"." expect(normalized_content).to eql(expected) end end