Sha256: 37c3eea440f9d0c41dbd7272daf450aaa18bec58dd0af78c429c16c8daac8778

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

require 'shoes/spec_helper'

main_object = self

describe Shoes::Font do
  describe 'font method on the main object' do
    it 'returns the name of the font loaded' do
      result = main_object.font(Shoes::FONT_DIR + "Coolvetica" + '.ttf')
      expect(result).to eq 'Coolvetica'
    end

    it 'calls the backend add_font method' do
      expect(Shoes.backend::Font).to receive :add_font
      main_object.font 'some/path'
    end
  end

  describe '.font_paths_from_dir' do
    it 'returns an array of the paths of the fonts in the directory' do
      result = Shoes::Font.font_paths_from_dir(Shoes::FONT_DIR)

      expect(result).to include(Shoes::FONT_DIR + 'Coolvetica.ttf',
                            Shoes::FONT_DIR + 'Lacuna.ttf')
    end

    it 'handles sub directories' do
      tmp_font_dir = Shoes::FONT_DIR + 'tmp/'
      Dir.mkdir(tmp_font_dir)
      tmp_font_path = tmp_font_dir + 'weird_font.ttf'
      FileUtils.touch tmp_font_path
      result = Shoes::Font.font_paths_from_dir(Shoes::FONT_DIR)
      expect(result).to include tmp_font_path
      FileUtils.rm_r tmp_font_dir
    end
  end

end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
shoes-core-4.0.0.pre4 spec/shoes/font_spec.rb
shoes-core-4.0.0.pre3 spec/shoes/font_spec.rb
shoes-swt-4.0.0.pre2 spec/shoes/font_spec.rb
shoes-dsl-4.0.0.pre2 spec/shoes/font_spec.rb