Sha256: e0b88a64a15c21106d6a692efabd0d691f90a617844e4fa3cbebe41116aa74fa

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

# encoding: utf-8

require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")

describe "#formatted_text" do
  it "should draw text" do
    create_pdf
    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
  before(:each) { create_pdf }

  it "should automatically move to a new page if the tallest fragment" \
     " on the next line won't fit in the available space" do
    create_pdf
    @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 "should embed 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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
prawn-2.1.0 spec/text_with_inline_formatting_spec.rb
prawn-2.0.2 spec/text_with_inline_formatting_spec.rb