Sha256: fc499d3ff5650412ba508d5dc148415a86fbaf0792be12a7081bdf6720214757

Contents?: true

Size: 1.81 KB

Versions: 2

Compression:

Stored size: 1.81 KB

Contents

require 'spec_helper'

describe Prawn::Svg::Interface do
  root = "#{File.dirname(__FILE__)}/../.."

  describe "sample file rendering" do
    files = Dir["#{root}/spec/sample_svg/*.svg"]

    it "has at least 10 SVG sample files to test" do
      files.length.should >= 10
    end

    files.each do |file|
      it "renders the #{File.basename file} sample file without warnings or crashing" do
        warnings = nil
        Prawn::Document.generate("#{root}/spec/sample_output/#{File.basename file}.pdf") do |prawn|
          r = prawn.svg IO.read(file), :at => [0, prawn.bounds.top], :width => prawn.bounds.width, :cache_images => true
          warnings = r[:warnings].reject {|w| w =~ /Verdana/ && w =~ /is not a known font/ }
        end
        warnings.should == []
      end
    end
  end

  describe "multiple file rendering" do
    it "renders multiple files on to the same PDF" do
      Prawn::Document.generate("#{root}/spec/sample_output/multiple.pdf") do |prawn|
        width = prawn.bounds.width

        y = prawn.bounds.top - 12
        prawn.draw_text "This is multiple SVGs being output to the same PDF", :at => [0, y]

        y -= 12
        prawn.svg IO.read("#{root}/spec/sample_svg/arcs01.svg"),   :at => [0, y],         :width => width / 2
        prawn.svg IO.read("#{root}/spec/sample_svg/circle01.svg"), :at => [width / 2, y], :width => width / 2

        y -= 120
        prawn.draw_text "Here are some more PDFs below", :at => [0, y]

        y -= 12
        prawn.svg IO.read("#{root}/spec/sample_svg/quad01.svg"), :at => [0, y],             :width => width / 3
        prawn.svg IO.read("#{root}/spec/sample_svg/rect01.svg"), :at => [width / 3, y],     :width => width / 3
        prawn.svg IO.read("#{root}/spec/sample_svg/rect02.svg"), :at => [width / 3 * 2, y], :width => width / 3
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
prawn-svg-0.15.0.0 spec/lib/svg_spec.rb
prawn-svg-0.12.0.12 spec/lib/svg_spec.rb