Sha256: da66fe20c8b184cb7708b291a5de82dadd21358362f49d2145c8d1c1ffb978c4

Contents?: true

Size: 1.68 KB

Versions: 2

Compression:

Stored size: 1.68 KB

Contents

# coding: utf-8

require File.dirname(__FILE__) + '/spec_helper'

context "The PDF::Wrapper class" do
  specify "should be able to detect the filetype of an image" do
    pdf = PDF::Wrapper.new
    pdf.detect_image_type(File.dirname(__FILE__) + "/data/google.png").should eql(:png)
    pdf.detect_image_type(File.dirname(__FILE__) + "/data/zits.gif").should eql(:gif)
    pdf.detect_image_type(File.dirname(__FILE__) + "/data/orc.svg").should eql(:svg)
    pdf.detect_image_type(File.dirname(__FILE__) + "/data/utf8-long.pdf").should eql(:pdf)
    pdf.detect_image_type(File.dirname(__FILE__) + "/data/shipsail.jpg").should eql(:jpg)
  end

  specify "should be able to determine image dimensions correctly" do
    pdf = PDF::Wrapper.new
    pdf.image_dimensions(File.dirname(__FILE__) + "/data/google.png").should eql([166,55])
    pdf.image_dimensions(File.dirname(__FILE__) + "/data/zits.gif").should eql([525,167])
    pdf.image_dimensions(File.dirname(__FILE__) + "/data/orc.svg").should eql([734, 772])
    pdf.image_dimensions(File.dirname(__FILE__) + "/data/utf8-long.pdf").map{ |d| d.to_i}.should eql([595,841])
    pdf.image_dimensions(File.dirname(__FILE__) + "/data/shipsail.jpg").should eql([192,128])
  end

  specify "should be able to calculate scaled image dimensions correctly" do
    pdf = PDF::Wrapper.new
    pdf.calc_image_dimensions(100, 100, 200, 200).should eql([100.0,100.0])
    pdf.calc_image_dimensions(nil, nil, 200, 200).should eql([200.0,200.0])
    pdf.calc_image_dimensions(150, 200, 200, 200, true).should eql([150.0,150.0])
    pdf.calc_image_dimensions(300, 250, 200, 200, true).should eql([250.0,250.0])
  end

  specify "should be able to draw an image with padding correctly"
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pdf-wrapper-0.0.7 specs/image_spec.rb
pdf-wrapper-0.1.0 specs/image_spec.rb