File: composite_spec.rb

package info (click to toggle)
ruby-pdf-reader 1.3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 12,908 kB
  • ctags: 569
  • sloc: ruby: 8,330; makefile: 10
file content (32 lines) | stat: -rw-r--r-- 1,093 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# coding: utf-8

require "spec_helper"

describe PDF::Reader::WidthCalculator::Composite do
  it_behaves_like "a WidthCalculator duck type" do
    let!(:font)       { double(:cid_default_width => 50,
                                :cid_widths        => [10,[30,40]])
                      }
    subject           { PDF::Reader::WidthCalculator::Composite.new(font)}
  end
end

describe PDF::Reader::WidthCalculator::Composite, "#glyph_width" do
  context "when font#cid_default_width is defined" do
    let!(:font)       { double(:cid_default_width => 50,
                                :cid_widths        => [10,[30,40]])
                      }
    subject           { PDF::Reader::WidthCalculator::Composite.new(font)}

    context "when the glyph code is provided in cid_widths" do
      it "should return the correct width" do
        subject.glyph_width(10).should == 30
      end
    end
    context "when the glyph code is equal to greater than font#first_char" do
      it "should return the default width" do
        subject.glyph_width(9).should == 50
      end
    end
  end
end