Sha256: d3f4751cc9379eb39b8affc4f6de6b22571edf4ea566aa3c991cd081136a4e11

Contents?: true

Size: 1.28 KB

Versions: 5

Compression:

Stored size: 1.28 KB

Contents

require "spec_helper"

RSpec.describe Fontist::SystemFont do
  describe ".find" do
    context "with a vlaid existing font" do
      it "returns the complete font path" do
        name = "DejaVuSerif.ttf"
        dejavu_ttf = Fontist::SystemFont.find(name, sources: [font_sources])

        expect(dejavu_ttf).not_to be_nil
        expect(dejavu_ttf.first).to include("spec/fixtures/fonts/")
      end
    end

    context "with valid font name" do
      it "returns the complete font path", slow: true do
        name = "Calibri"
        stub_fontist_path_to_temp_path
        Fontist::Formulas::ClearTypeFonts.fetch_font(name, confirmation: "yes")

        calbiri = Fontist::SystemFont.find(name, sources: [font_sources])
        expect(calbiri.join("|").downcase).to include("#{name.downcase}.ttf")
      end
    end

    context "with invalid font" do
      it "returns nil for partial-not match" do
        name = "Deje"
        expect(Fontist::SystemFont.find(name)).to be_nil
      end

      it "returns nill to the caller" do
        name = "invalid-font.ttf"
        invalid_font = Fontist::SystemFont.find(name, sources: [font_sources])

        expect(invalid_font).to be_nil
      end
    end
  end

  def font_sources
    @font_sources ||= Fontist.root_path.join("spec/fixtures/fonts/*")
  end
end

Version data entries

5 entries across 4 versions & 2 rubygems

Version Path
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/fontist-1.1.0/spec/fontist/system_font_spec.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/fontist-1.2.0/spec/fontist/system_font_spec.rb
fontist-1.2.0 spec/fontist/system_font_spec.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/fontist-1.1.0/spec/fontist/system_font_spec.rb
fontist-1.1.0 spec/fontist/system_font_spec.rb