Sha256: 6ece04cb104d91b74a9f6d54cbf2c0ed4731853be8a776c5410bdfb5b653a52d

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe Prawn::Text do
  let(:pdf) { create_pdf }

  describe '#formatted_text' do
    it 'draws text' do
      string = 'hello world'
      format_array = [text: string]
      pdf.formatted_text(format_array)
      # grab the text from the rendered PDF and ensure it matches
      text = PDF::Inspector::Text.analyze(pdf.render)
      expect(text.strings.first).to eq(string)
    end
  end

  describe '#text with inline styling' do
    it 'should automatically move to a new page if the tallest fragment' \
      " on the next line won't fit in the available space" do
      pdf.move_cursor_to(pdf.font.height)
      formatted = "this contains <font size='24'>sized</font> text"
      pdf.text(formatted, inline_format: true)
      pages = PDF::Inspector::Page.analyze(pdf.render).pages
      expect(pages.size).to eq(2)
    end

    it 'embeds links as literal strings' do
      pdf.text "<link href='http://wiki.github.com/sandal/prawn/'>wiki</link>",
        inline_format: true
      expect(pdf.render).to match(%r{/URI\s+\(http://wiki\.github\.com})
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
prawn-2.2.2 spec/prawn/text_with_inline_formatting_spec.rb
prawn-2.2.1 spec/prawn/text_with_inline_formatting_spec.rb
prawn-2.2.0 spec/prawn/text_with_inline_formatting_spec.rb