# frozen_string_literal: true require 'spec_helper' describe USPSFlags::Burgees do it 'returns the list of available burgees from available' do expect(described_class.available).to eql([:birmingham]) end it 'raises USPSFlags::Errors::UnknownBurgee if an invalid burgee is entered' do @burgee = described_class.new do |b| b.squadron = :not_a_squadron b.outfile = '' end expect { @burgee.svg }.to raise_error(USPSFlags::Errors::UnknownBurgee) end it 'generates a burgee from the builtins' do @burgee = described_class.new do |b| b.squadron = :birmingham b.outfile = '' end expect(@burgee.svg).to include( <<~SVG This image is a registered trademark of United States Power Squadrons. https://www.usps.org/images/secretary/itcom/trademark.pdf SVG ) end it 'generates a burgee from the custom directory' do @custom_file = "#{USPSFlags.configuration.burgees_dir}/custom_birmingham.svg" ::FileUtils.mkdir_p(USPSFlags.configuration.burgees_dir) ::FileUtils.cp('lib/usps_flags/burgees/builtins/birmingham.svg', @custom_file) burgee = ::File.read(@custom_file).gsub('Birmingham Burgee', 'Custom Birmingham Burgee') f = ::File.open(@custom_file, 'w+') f.write(burgee) f.close @burgee = described_class.new do |b| b.squadron = :custom_birmingham b.outfile = '' end expect(@burgee.svg).to include('Custom Birmingham Burgee') ::FileUtils.rm_rf(USPSFlags.configuration.burgees_dir) end describe 'crossed-staves burgee' do it 'has the crossed flags' do @burgee = described_class.new do |b| b.squadron = :birmingham b.outfile = '' end expect(@burgee.svg(crossed: true)).to include('