public
Description: Fast, Nimble PDF Writer for Ruby
Homepage: http://prawn.majesticseacreature.com
Clone URL: git://github.com/sandal/prawn.git
Added simple spec for image()'s :fit argument
trym (author)
Wed Oct 29 12:01:49 -0700 2008
commit  7a3fb931a003547ef77951d778e043bf275a99c1
tree    bf109676c117114144721dec022d28470b4ec31b
parent  e020ec959dde98a510d030eea099a40e9819ee0b
...
17
18
19
20
21
22
23
...
36
37
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
40
...
17
18
19
 
20
21
22
...
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
0
@@ -17,7 +17,6 @@ describe "the image() function" do
0
     images = PDF::Inspector::XObject.analyze(output)
0
     # there should be 2 images in the page resources
0
     images.page_xobjects.first.size.should == 2
0
-
0
     # but only 1 image xobject
0
     output.scan(/\/Type \/XObject/).size.should == 1
0
   end  
0
@@ -36,5 +35,20 @@ describe "the image() function" do
0
     
0
     info.height.should == 453
0
   end
0
+  
0
+  it "should fit inside the defined constraints" do
0
+    info = @pdf.image @filename, :fit => [100,400]
0
+    info.scaled_width.should <= 100
0
+    info.scaled_height.should <= 400
0
+    
0
+    info = @pdf.image @filename, :fit => [400,100]
0
+    info.scaled_width.should <= 400
0
+    info.scaled_height.should <= 100
0
+    
0
+    info = @pdf.image @filename, :fit => [604,453]
0
+    info.scaled_width.should == 604
0
+    info.scaled_height.should == 453
0
+  end
0
+  
0
 end
0
 

Comments