|
eeb7aa92
»
|
mdaines |
2008-05-26 |
Allow the "height" argument... |
1 |
require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper") |
|
bc369eb9
»
|
Gregory Brown |
2008-05-18 |
Initial work on bounding boxen |
2 |
|
| |
3 |
describe "A bounding box" do |
| |
4 |
|
| |
5 |
before(:each) do |
|
eeb7aa92
»
|
mdaines |
2008-05-26 |
Allow the "height" argument... |
6 |
@box = Prawn::Document::BoundingBox.new(nil, [100,100], :width => 50, |
| |
7 |
:height => 75 ) |
|
bc369eb9
»
|
Gregory Brown |
2008-05-18 |
Initial work on bounding boxen |
8 |
end |
| |
9 |
|
| |
10 |
it "should have an anchor at (x, y - height)" do |
| |
11 |
@box.anchor.should == [100,25] |
| |
12 |
end |
| |
13 |
|
| |
14 |
it "should have a left boundary of 0" do |
| |
15 |
@box.left.should == 0 |
| |
16 |
end |
| |
17 |
|
| |
18 |
it "should have a right boundary equal to the width" do |
| |
19 |
@box.right.should == 50 |
| |
20 |
end |
| |
21 |
|
| |
22 |
it "should have a top boundary of height" do |
| |
23 |
@box.top.should == 75 |
| |
24 |
end |
| |
25 |
|
| |
26 |
it "should have a bottom boundary of 0" do |
| |
27 |
@box.bottom.should == 0 |
| |
28 |
end |
| |
29 |
|
| |
30 |
it "should have an absolute left boundary of x" do |
| |
31 |
@box.absolute_left.should == 100 |
| |
32 |
end |
| |
33 |
|
| |
34 |
it "should have an absolute right boundary of x + width" do |
| |
35 |
@box.absolute_right.should == 150 |
| |
36 |
end |
| |
37 |
|
| |
38 |
it "should have an absolute top boundary of y" do |
| |
39 |
@box.absolute_top.should == 100 |
| |
40 |
end |
| |
41 |
|
| |
42 |
it "should have an absolute bottom boundary of y - height" do |
| |
43 |
@box.absolute_bottom.should == 25 |
| |
44 |
end |
| |
45 |
|
| |
46 |
end |
|
55e90a1e
»
|
sandal |
2008-06-20 |
Test nested bounding boxes.... |
47 |
|
| |
48 |
describe "drawing bounding boxes" do |
| |
49 |
|
| |
50 |
it "should restore the margin box when bounding box exits" do |
| |
51 |
@pdf = Prawn::Document.new |
| |
52 |
margin_box = @pdf.bounds |
| |
53 |
|
| |
54 |
@pdf.bounding_box [100,500] do |
| |
55 |
#nothing |
| |
56 |
end |
| |
57 |
|
| |
58 |
@pdf.bounds.should == margin_box |
| |
59 |
|
| |
60 |
end |
| |
61 |
|
| |
62 |
it "should restore the parent bounding box when calls are nested" do |
| |
63 |
@pdf = Prawn::Document.new |
| |
64 |
@pdf.bounding_box [100,500], :width => 300, :height => 300 do |
| |
65 |
|
| |
66 |
@pdf.bounds.absolute_top.should == 500 |
| |
67 |
@pdf.bounds.absolute_left.should == 100 |
| |
68 |
|
| |
69 |
@pdf.bounding_box [50,200], :width => 100, :height => 100 do |
| |
70 |
@pdf.bounds.absolute_top.should == 200 |
| |
71 |
@pdf.bounds.absolute_left.should == 50 |
| |
72 |
end |
| |
73 |
|
| |
74 |
@pdf.bounds.absolute_top.should == 500 |
| |
75 |
@pdf.bounds.absolute_left.should == 100 |
| |
76 |
|
| |
77 |
end |
| |
78 |
end |
| |
79 |
end |