summaryrefslogtreecommitdiff
path: root/spec/pass_spec.rb
blob: 0371efe24bfe9502a10f1a568b1f30e995de9dce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# frozen_string_literal: true

require_relative 'spec_helper'

describe 'Asciidoctor::PDF::Converter - Pass' do
  it 'should render pass as plain literal block' do
    pdf = to_pdf <<~'END', pdf_theme: { base_font_color: '222222', code_font_color: '0000EE' }, analyze: true
    ++++
    <p>
    stay
      calm
    and
      <strong>pass</strong>
    through
    </p>
    ++++
    END

    all_text = pdf.text
    (expect all_text.size).to be > 1
    all_text.each do |text|
      (expect text[:font_color]).to eql '222222'
      (expect text[:font_name]).to eql 'mplus1mn-regular'
    end
    (expect all_text[0][:string]).to eql '<p>'
    (expect all_text[4][:string]).to eql %(\u00a0 <strong>pass</strong>)
  end

  it 'should add bottom margin to pass block' do
    pdf = to_pdf <<~'END', analyze: true
    ++++
    This is a pass block.
    ++++

    This is a paragraph.
    END

    pass_text = pdf.find_unique_text 'This is a pass block.'
    para_text = pdf.find_unique_text 'This is a paragraph.'
    margin_bottom = pass_text[:y] - (para_text[:y] + para_text[:font_size])
    (expect margin_bottom).to be > 12
  end
end