Sha256: fdcbd7c87781e0ce0450fb088bd1f25b8886f16471c76d5463e377e6a721a26a
Contents?: true
Size: 1.48 KB
Versions: 2
Compression:
Stored size: 1.48 KB
Contents
# frozen_string_literal: true require 'spec_helper' require 'pathname' describe Prawn::FontMetricCache do let(:document) { Prawn::Document.new } let(:font_metric_cache) { described_class.new(document) } it 'starts with an empty cache' do expect(font_metric_cache.instance_variable_get(:@cache)).to be_empty end it 'caches the width of the provided string' do font_metric_cache.width_of('M', {}) expect(font_metric_cache.instance_variable_get(:@cache).size).to eq(1) end it 'onlies cache a single copy of the same string' do font_metric_cache.width_of('M', {}) font_metric_cache.width_of('M', {}) expect(font_metric_cache.instance_variable_get(:@cache).size).to eq(1) end it 'caches different copies for different strings' do font_metric_cache.width_of('M', {}) font_metric_cache.width_of('W', {}) expect(font_metric_cache.instance_variable_get(:@cache).entries.size) .to eq 2 end it 'caches different copies of the same string with different font sizes' do font_metric_cache.width_of('M', {}) document.font_size 24 font_metric_cache.width_of('M', {}) expect(font_metric_cache.instance_variable_get(:@cache).entries.size) .to eq 2 end it 'caches different copies of the same string with different fonts' do font_metric_cache.width_of('M', {}) document.font 'Courier' font_metric_cache.width_of('M', {}) expect(font_metric_cache.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.4.0 | spec/prawn/font_metric_cache_spec.rb |
prawn-2.3.0 | spec/prawn/font_metric_cache_spec.rb |