Sha256: af01c68e2ff843c67aa41becee566e2cd0a62a954f6818a1dd8c7808c014e222

Contents?: true

Size: 977 Bytes

Versions: 9

Compression:

Stored size: 977 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

describe DocTemplate::Tags::PageBreakTag do
  let(:node) { Nokogiri::HTML(original_content).at_xpath('*//p') }
  let(:original_content) { '<p><span>[page-break]</span></p>' }
  let(:options) { {} }
  let(:tag) { described_class.new }
  let(:cls) { 'u-pdf-alwaysbreak do-not-strip' }

  subject { tag.parse(node, options).content }

  it 'substitutes the tag' do
    expect(subject).to_not include '[page-break]'
    expect(subject).to include %(<div class="#{cls}">)
  end

  context 'when it is GDoc view' do
    let(:options) { { context_type: 'gdoc' } }

    it 'substitutes the tag' do
      expect(subject).to_not include '[page-break]'
      expect(subject).to include '<p>--GDOC-PAGE-BREAK--</p>'
    end
  end

  context 'with soft returns on tag' do
    let(:original_content) { '<p><span>[page-break]</span>some content</p>' }

    it { expect { subject }.to raise_error(Lcms::Engine::DocumentError) }
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
lcms-engine-0.5.5 spec/lib/doc_template/tags/page_break_tag_spec.rb
lcms-engine-0.5.4 spec/lib/doc_template/tags/page_break_tag_spec.rb
lcms-engine-0.5.3 spec/lib/doc_template/tags/page_break_tag_spec.rb
lcms-engine-0.5.2 spec/lib/doc_template/tags/page_break_tag_spec.rb
lcms-engine-0.5.1 spec/lib/doc_template/tags/page_break_tag_spec.rb
lcms-engine-0.5.0 spec/lib/doc_template/tags/page_break_tag_spec.rb
lcms-engine-0.4.2 spec/lib/doc_template/tags/page_break_tag_spec.rb
lcms-engine-0.4.1 spec/lib/doc_template/tags/page_break_tag_spec.rb
lcms-engine-0.4.0 spec/lib/doc_template/tags/page_break_tag_spec.rb