Sha256: 8af5fa343a0ca7b7ebf050cc2738c2b98c3862845e8d64ed1865982c7691936c

Contents?: true

Size: 1.18 KB

Versions: 13

Compression:

Stored size: 1.18 KB

Contents

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

describe Prawn::Svg::Document do  
  before(:each) do
    @document = Prawn::Svg::Document.new("<svg></svg>", [100, 100], {})
  end

  describe :points do    
    it "converts a variety of measurement units to points" do
      @document.send(:points, 32).should == 32.0      
      @document.send(:points, 32.0).should == 32.0      
      @document.send(:points, "32").should == 32.0
      @document.send(:points, "32unknown").should == 32.0
      @document.send(:points, "32pt").should == 32.0      
      @document.send(:points, "32in").should == 32.0 * 72
      @document.send(:points, "32ft").should == 32.0 * 72 * 12
      @document.send(:points, "32mm").should be_within(0.0001).of(32 * 72 * 0.0393700787)
      @document.send(:points, "32cm").should be_within(0.0001).of(32 * 72 * 0.393700787)
      @document.send(:points, "32m").should be_within(0.0001).of(32 * 72 * 39.3700787)
      
      @document.send :instance_variable_set, "@actual_width", 600
      @document.send :instance_variable_set, "@actual_height", 400
      @document.send(:points, "50%").should == 300
      @document.send(:points, "50%", :y).should == 200
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
prawn-svg-0.15.0.0 spec/prawn/svg/document_spec.rb
prawn-svg-0.12.0.12 spec/prawn/svg/document_spec.rb
prawn-svg-0.12.0.11 spec/prawn/svg/document_spec.rb
prawn-svg-0.12.0.10 spec/prawn/svg/document_spec.rb
prawn-svg-0.12.0.9 spec/prawn/svg/document_spec.rb
prawn-svg-0.12.0.8 spec/prawn/svg/document_spec.rb
prawn-svg-0.12.0.7 spec/prawn/svg/document_spec.rb
prawn-svg-0.12.0.6 spec/prawn/svg/document_spec.rb
prawn-svg-0.12.0.4 spec/prawn/svg/document_spec.rb
prawn-svg-0.12.0.3 spec/prawn/svg/document_spec.rb
prawn-svg-0.12.0.2 spec/prawn/svg/document_spec.rb
prawn-svg-0.12.0.1 spec/prawn/svg/document_spec.rb
prawn-svg-0.9.1.11 spec/prawn/svg/document_spec.rb