Sha256: e24874c72c588debc663b718b4971232ae297260127057cb20deaf2b976004b9

Contents?: true

Size: 1.24 KB

Versions: 7

Compression:

Stored size: 1.24 KB

Contents

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

describe Prawn::Svg::Element do
  before :each do
    e = mock
    e.stub!(:attributes).and_return({})

    @document = Struct.new(:fallback_font_name, :css_parser, :warnings).new("Courier", nil, [])
    @element = Prawn::Svg::Element.new(@document, e, [], {})
  end

  describe :parse_font_attributes_and_call do
    it "uses a font if it can find it" do
      @element.should_receive(:add_call_and_enter).with('font', 'Helvetica', :style => :normal)

      @element.attributes["font-family"] = "Helvetica"
      @element.send :parse_font_attributes_and_call
    end

    it "uses the fallback font if the requested font is not defined" do
      @element.should_receive(:add_call_and_enter).with('font', 'Courier', :style => :normal)

      @element.attributes["font-family"] = "Font That Doesn't Exist"
      @element.send :parse_font_attributes_and_call
    end

    it "doesn't call the font method if there's no fallback font" do
      @document.fallback_font_name = nil

      @element.should_not_receive(:add_call_and_enter)

      @element.attributes["font-family"] = "Font That Doesn't Exist"
      @element.send :parse_font_attributes_and_call
      @document.warnings.length.should == 1
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
prawn-svg-0.12.0.12 spec/prawn/svg/element_spec.rb
prawn-svg-0.12.0.11 spec/prawn/svg/element_spec.rb
prawn-svg-0.12.0.10 spec/prawn/svg/element_spec.rb
prawn-svg-0.12.0.9 spec/prawn/svg/element_spec.rb
prawn-svg-0.12.0.8 spec/prawn/svg/element_spec.rb
prawn-svg-0.12.0.7 spec/prawn/svg/element_spec.rb
prawn-svg-0.12.0.6 spec/prawn/svg/element_spec.rb