Sha256: 967095c77bb67cffa1335e1d89cdee344493d4dc2243e50b159e348b23101273
Contents?: true
Size: 1.77 KB
Versions: 4
Compression:
Stored size: 1.77 KB
Contents
# encoding: utf-8 require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper") describe "the image() function" do before(:each) do @filename = "#{Prawn::BASEDIR}/data/images/pigs.jpg" create_pdf end it "should only embed an image once, even if it's added multiple times" do @pdf.image @filename, :at => [100,100] @pdf.image @filename, :at => [300,300] output = @pdf.render images = PDF::Inspector::XObject.analyze(output) # there should be 2 images in the page resources images.page_xobjects.first.size.should == 2 # but only 1 image xobject output.scan(/\/Type \/XObject/).size.should == 1 end it "should return the image info object" do info = @pdf.image(@filename) assert info.kind_of?(Prawn::Images::JPG) info.height.should == 453 end it "should accept IO objects" do file = File.open(@filename, "rb") info = @pdf.image(file) info.height.should == 453 end describe ":fit option" do it "should fit inside the defined constraints" do info = @pdf.image @filename, :fit => [100,400] info.scaled_width.should <= 100 info.scaled_height.should <= 400 info = @pdf.image @filename, :fit => [400,100] info.scaled_width.should <= 400 info.scaled_height.should <= 100 info = @pdf.image @filename, :fit => [604,453] info.scaled_width.should == 604 info.scaled_height.should == 453 end it "should move text position" do @y = @pdf.y info = @pdf.image @filename, :fit => [100,400] @pdf.y.should < @y end end describe ":at option" do it "should not move text position" do @y = @pdf.y info = @pdf.image @filename, :at => [100,400] @pdf.y.should == @y end end end
Version data entries
4 entries across 4 versions & 3 rubygems