Sha256: 21d67e8701737b51e01fc149ae3e203e63530945bb78b50df7ca3602849425cc

Contents?: true

Size: 1.13 KB

Versions: 13

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

describe DocTemplate::Tables::Metadata do
  let(:table) { described_class.new }

  describe '#parse' do
    let(:html) { Lcms::Engine::HtmlSanitizer.sanitize(data) }
    let(:fragment) { Nokogiri::HTML.fragment html }

    subject { table.parse fragment }

    shared_examples 'process metadata table' do
      include_examples 'removes metadata table'

      it { expect(subject.data['type']).to eq 'lesson' }
      it { expect(subject.data['guidebook-type']).to eq 'D2' }
      it { expect(subject.data['guidebook-title']).to eq 'A Lesson Before Dying' }
    end

    context 'regular header' do
      let(:data) { file_fixture('tables/document-metadata.html').read }

      include_examples 'process metadata table'
    end

    context 'header with spans' do
      let(:data) { file_fixture('tables/document-metadata-2spans.html').read }

      include_examples 'process metadata table'
    end

    context '2 paragraphs header with space' do
      let(:data) { file_fixture('tables/document-metadata-2paragpraphs.html').read }

      include_examples 'process metadata table'
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
lcms-engine-0.5.5 spec/lib/doc_template/tables/metadata_spec.rb
lcms-engine-0.5.4 spec/lib/doc_template/tables/metadata_spec.rb
lcms-engine-0.5.3 spec/lib/doc_template/tables/metadata_spec.rb
lcms-engine-0.5.2 spec/lib/doc_template/tables/metadata_spec.rb
lcms-engine-0.5.1 spec/lib/doc_template/tables/metadata_spec.rb
lcms-engine-0.5.0 spec/lib/doc_template/tables/metadata_spec.rb
lcms-engine-0.4.2 spec/lib/doc_template/tables/metadata_spec.rb
lcms-engine-0.4.1 spec/lib/doc_template/tables/metadata_spec.rb
lcms-engine-0.4.0 spec/lib/doc_template/tables/metadata_spec.rb
lcms-engine-0.3.1 spec/lib/doc_template/tables/metadata_spec.rb
lcms-engine-0.1.4 spec/lib/doc_template/tables/metadata_spec.rb
lcms-engine-0.3.0 spec/lib/doc_template/tables/metadata_spec.rb
lcms-engine-0.1.3 spec/lib/doc_template/tables/metadata_spec.rb