Sha256: e8afdeefe6a7d4b9f2d8aa53733cb3b2b4e39427f3b6766d637a9cf44b145c06
Contents?: true
Size: 1.79 KB
Versions: 2
Compression:
Stored size: 1.79 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe Prawn::TransformationStack do let(:pdf) do create_pdf do |document| document.add_to_transformation_stack(2, 0, 0, 2, 100, 100) end end let(:stack) { pdf.instance_variable_get(:@transformation_stack) } describe '#add_to_transformation_stack' do it 'creates and adds to the stack' do pdf.add_to_transformation_stack(1, 0, 0, 1, 20, 20) expect(stack).to eq [[[2, 0, 0, 2, 100, 100], [1, 0, 0, 1, 20, 20]]] end it 'adds to the last stack' do pdf.save_transformation_stack pdf.add_to_transformation_stack(1, 0, 0, 1, 20, 20) expect(stack).to eq [ [[2, 0, 0, 2, 100, 100]], [[2, 0, 0, 2, 100, 100], [1, 0, 0, 1, 20, 20]] ] end end describe '#save_transformation_stack' do it 'clones the last stack' do pdf.save_transformation_stack expect(stack.length).to eq 2 expect(stack.first).to eq stack.last expect(stack.first).to_not be stack.last end end describe '#restore_transformation_stack' do it 'pops off the last stack' do pdf.save_transformation_stack pdf.add_to_transformation_stack(1, 0, 0, 1, 20, 20) pdf.restore_transformation_stack expect(stack).to eq [[[2, 0, 0, 2, 100, 100]]] end end describe 'current_transformation_matrix_with_translation' do before do pdf.add_to_transformation_stack(1, 0, 0, 1, 20, 20) end it 'calculates the last transformation' do expect(pdf.current_transformation_matrix_with_translation) .to eq [2, 0, 0, 2, 140, 140] end it 'adds the supplied x and y coordinates to the transformation stack' do expect(pdf.current_transformation_matrix_with_translation(15, 15)) .to eq [2, 0, 0, 2, 170, 170] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
prawn-2.4.0 | spec/prawn/transformation_stack_spec.rb |
prawn-2.3.0 | spec/prawn/transformation_stack_spec.rb |