Sha256: 5514eb9ff5b212f5297d23ba2004f51256ee8940c2f8a022c65217f6c2265795

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

#
# specifying podoff
#
# Fri Oct 23 08:36:38 JST 2015
#

require 'spec_helper'


describe Podoff::Stream do

  describe '#tf' do

    it 'sets the current font' do

      st = Podoff::Stream.new

      st.tf('/Helvetica', 35)
      st.bt(10, 20, 'helvetic')
      st.tf('/ZapfDingbats', 21)
      st.bt(10, 50, 'zapfesque')

      expect(st.to_s).to eq(%{
BT /Helvetica 35 Tf 10 20 Td (helvetic) Tj ET
BT /ZapfDingbats 21 Tf 10 50 Td (zapfesque) Tj ET
      }.strip)
    end
  end

  describe '#bt' do

    it 'works' do

      st = Podoff::Stream.new
      st.bt(10, 20, 'hello world')

      expect(st.to_s).to eq('BT 10 20 Td (hello world) Tj ET')
    end

    it 'escapes the text' do

      st = Podoff::Stream.new
      st.bt(10, 20, 'hello()world')

      expect(st.to_s).to eq('BT 10 20 Td (hello\(\)world) Tj ET')
    end
  end

  describe '#write' do

    it 'injects text into the stream' do

      st = Podoff::Stream.new
      st.bt(10, 20, 'abc')
      st.write("\nBT 25 35 Td (ABC) Tj ET")
      st.bt(30, 40, 'def')

      expect(st.to_s).to eq(%{
BT 10 20 Td (abc) Tj ET
BT 25 35 Td (ABC) Tj ET
BT 30 40 Td (def) Tj ET
      }.strip)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
podoff-1.1.0 spec/stream_spec.rb
podoff-1.0.0 spec/stream_spec.rb