Sha256: 0cdad539bd737dac5001945653c34b6b5ee95f92820bb2146515a610d640a005

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

require 'tmpdir'
require 'spec_helper'
require 'exogenesis/passengers/fonts'

describe Fonts do

  let(:config) { double }

  before {
    temp_dir = Dir.mktmpdir
    FileUtils.touch File.join(temp_dir, 'roboto.ttf')
    FileUtils.touch File.join(temp_dir, 'bignoodle.otf')
    allow(config).to receive(:fonts_path).and_return(temp_dir)
  }

  let(:executor) { executor_double }
  subject { Fonts.new(config, executor) }

  after do
    FileUtils.remove_entry_secure config.fonts_path
  end

  describe :up do

    it 'should copy fonts if they are not found' do
      expect(executor).to receive(:execute)
        .with('Copying roboto.ttf', "cp '#{config.fonts_path}/roboto.ttf' '#{ENV['HOME']}/Library/Fonts/roboto.ttf'")
      expect(executor).to receive(:execute)
        .with('Copying bignoodle.otf', "cp '#{config.fonts_path}/bignoodle.otf' '#{ENV['HOME']}/Library/Fonts/bignoodle.otf'")
      subject.up
    end

    it 'should skip fonts if they are found' do
      expect(File).to receive(:exist?).and_return(true).twice
      expect(executor).to receive(:skip_task)
        .with('Copying roboto.ttf', 'Already copied')
      expect(executor).to receive(:skip_task)
        .with('Copying bignoodle.otf', 'Already copied')
      subject.up
    end
  end

  describe :down do

    it 'should remove the fonts if they are found' do
      expect(executor).to receive(:rm_rf)
        .with("#{ENV['HOME']}/Library/Fonts/roboto.ttf")
      expect(executor).to receive(:rm_rf)
        .with("#{ENV['HOME']}/Library/Fonts/bignoodle.otf")
      subject.down
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
exogenesis-1.0.0 spec/unit/fonts_spec.rb