Sha256: 41640d700c612c8af2269546962a66a18accf38c8dca3220f7430b3e1ee64439

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'

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

  describe '#text_rendering_mode' do
    it 'draws the text rendering mode to the document' do
      pdf.text_rendering_mode(:stroke) do
        pdf.text('hello world')
      end
      contents = PDF::Inspector::Text.analyze(pdf.render)
      expect(contents.text_rendering_mode.first).to eq(1)
    end
    it 'should not draw the text rendering mode to the document' \
      ' when the new mode matches the old' do
      pdf.text_rendering_mode(:fill) do
        pdf.text('hello world')
      end
      contents = PDF::Inspector::Text.analyze(pdf.render)
      expect(contents.text_rendering_mode).to be_empty
    end
    it 'restores character spacing to 0' do
      pdf.text_rendering_mode(:stroke) do
        pdf.text('hello world')
      end
      contents = PDF::Inspector::Text.analyze(pdf.render)
      expect(contents.text_rendering_mode).to eq([1, 0])
    end
    it 'functions as an accessor when no parameter given' do
      pdf.text_rendering_mode(:fill_stroke) do
        pdf.text('hello world')
        expect(pdf.text_rendering_mode).to eq(:fill_stroke)
      end
      expect(pdf.text_rendering_mode).to eq(:fill)
    end
    it 'raise_errors an exception when passed an invalid mode' do
      expect { pdf.text_rendering_mode(-1) }.to raise_error(ArgumentError)
      expect { pdf.text_rendering_mode(8) }.to raise_error(ArgumentError)
      expect { pdf.text_rendering_mode(:flil) }.to raise_error(ArgumentError)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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