Sha256: 5326f11698bbb58f7ee3de4fb03f2d39a81be1070536ff5aa7b6ed79a2696c76

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

describe Prawn::Svg::Parser::Path do
  before :each do
    @path = Prawn::Svg::Parser::Path.new
  end
  
  describe "command parsing" do    
    it "correctly parses a valid path" do
      calls = []
      @path.stub!(:run_path_command) {|*args| calls << args}
      @path.parse("A12.34 -56.78 89B4 5   C  6,7 T QX 0 Z")
      
      calls.should == [
        ["A", [12.34, -56.78, 89]],
        ["B", [4, 5]],
        ["C", [6, 7]],
        ["T", []],
        ["Q", []],
        ["X", [0]],
        ["Z", []]
      ]      
    end
    
    it "correctly parses an empty path" do
      @path.should_not_receive(:run_path_command)
      @path.parse("").should == []
      @path.parse("   ").should == []
    end
    
    it "raises on invalid characters in the path" do
      lambda {@path.parse("M 10 % 20")}.should raise_error(Prawn::Svg::Parser::Path::InvalidError)
    end
    
    it "raises on numerical data before a command letter" do
      lambda {@path.parse("10 P")}.should raise_error(Prawn::Svg::Parser::Path::InvalidError)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
prawn-svg-0.12.0.3 spec/lib/path_spec.rb
prawn-svg-0.12.0.2 spec/lib/path_spec.rb
prawn-svg-0.12.0.1 spec/lib/path_spec.rb