Sha256: b6f760c26356ef6d229e1faeb2163e06b3009f58fc7de657b53a05606fc967f3
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
# encoding: utf-8 require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper") require 'pathname' describe "Font metrics caching" do let(:document) { Prawn::Document.new } subject { Prawn::FontMetricCache.new(document) } it "should start with an empty cache" do expect(subject.instance_variable_get(:@cache)).to be_empty end it "should cache the width of the provided string" do subject.width_of('M', {}) expect(subject.instance_variable_get(:@cache).size).to eq(1) end it "should only cache a single copy of the same string" do subject.width_of('M', {}) subject.width_of('M', {}) expect(subject.instance_variable_get(:@cache).size).to eq(1) end it "should cache different copies for different strings" do subject.width_of('M', {}) subject.width_of('W', {}) expect(subject.instance_variable_get(:@cache).entries.size).to eq(2) end it "should cache different copies of the same string with different font sizes" do subject.width_of('M', {}) document.font_size 24 subject.width_of('M', {}) expect(subject.instance_variable_get(:@cache).entries.size).to eq(2) end it "should cache different copies of the same string with different fonts" do subject.width_of('M', {}) document.font 'Courier' subject.width_of('M', {}) expect(subject.instance_variable_get(:@cache).entries.size).to eq(2) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
prawn-2.1.0 | spec/font_metric_cache_spec.rb |
prawn-2.0.2 | spec/font_metric_cache_spec.rb |