Sha256: 9c805c7f3cfdb5e61a3d8e691622aca19bc5362d81853c8075645bc971997be8

Contents?: true

Size: 1.4 KB

Versions: 7

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

describe Prawn::SVG::Attributes::Transform do
  class TransformTestElement
    include Prawn::SVG::Attributes::Transform

    attr_accessor :attributes, :warnings

    def initialize
      @warnings = []
      @attributes = {}
    end
  end

  let(:element) { TransformTestElement.new }

  subject { element.send :parse_transform_attribute_and_call }

  context "when a non-identity matrix is requested" do
    let(:transform) { 'translate(-5.5)' }

    it "passes the transform and executes the returned matrix" do
      expect(element).to receive(:parse_transform_attribute).with(transform).and_return([1, 2, 3, 4, 5, 6])
      expect(element).to receive(:add_call_and_enter).with('transformation_matrix', 1, 2, 3, 4, 5, 6)

      element.attributes['transform'] = transform
      subject
    end
  end

  context "when an identity matrix is requested" do
    let(:transform) { 'translate(0)' }

    it "does not execute any commands" do
      expect(element).to receive(:parse_transform_attribute).with(transform).and_return([1, 0, 0, 1, 0, 0])
      expect(element).not_to receive(:add_call_and_enter)

      element.attributes['transform'] = transform
      subject
    end
  end

  context "when transform is blank" do
    it "does nothing" do
      expect(element).not_to receive(:parse_transform_attribute)
      expect(element).not_to receive(:add_call_and_enter)

      subject
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
prawn-svg-0.34.2 spec/prawn/svg/attributes/transform_spec.rb
prawn-svg-0.34.1 spec/prawn/svg/attributes/transform_spec.rb
prawn-svg-0.34.0 spec/prawn/svg/attributes/transform_spec.rb
prawn-svg-0.33.0 spec/prawn/svg/attributes/transform_spec.rb
prawn-svg-0.32.0 spec/prawn/svg/attributes/transform_spec.rb
prawn-svg-0.31.0 spec/prawn/svg/attributes/transform_spec.rb
prawn-svg-0.30.0 spec/prawn/svg/attributes/transform_spec.rb