require 'spec_helper' describe USPSFlags::Generate do describe "general features" do it "should generate a flag with the correct size" do expect(USPSFlags::Generate.svg("LtC", outfile: "")).to include( "width=\"1024pt\" height=\"682pt\" viewBox=\"0 0 3072 2048\"" ) end it "should generate a flag with the correct field" do expect(USPSFlags::Generate.svg("LtC", outfile: "")).to include( <<~SVG SVG ) end it "should generate a flag with the correct starting position" do expect(USPSFlags::Generate.svg("LtC", outfile: "")).to include("") expect(USPSFlags::Generate.svg("LtC", outfile: "")).to include("") end end describe "line flags" do it "should generate CC" do expect(USPSFlags::Generate.svg("CC", outfile: "")).to include("CC") end it "should generate VC" do expect(USPSFlags::Generate.svg("VC", outfile: "")).to include("VC") end it "should generate RC" do expect(USPSFlags::Generate.svg("RC", outfile: "")).to include("RC") end it "should generate StfC" do expect(USPSFlags::Generate.svg("StfC", outfile: "")).to include("STFC") end it "should generate DC" do expect(USPSFlags::Generate.svg("DC", outfile: "")).to include("DC") end it "should generate DLtC" do expect(USPSFlags::Generate.svg("DLtC", outfile: "")).to include("DLTC") end it "should generate D1Lt" do expect(USPSFlags::Generate.svg("D1Lt", outfile: "")).to include("D1LT") end it "should generate DLt" do expect(USPSFlags::Generate.svg("DLt", outfile: "")).to include("DLT") end it "should generate Cdr" do expect(USPSFlags::Generate.svg("Cdr", outfile: "")).to include("CDR") end it "should generate LtC" do expect(USPSFlags::Generate.svg("LtC", outfile: "")).to include("LTC") end it "should generate 1Lt" do expect(USPSFlags::Generate.svg("1Lt", outfile: "")).to include("1LT") end it "should generate Lt" do expect(USPSFlags::Generate.svg("Lt", outfile: "")).to include("LT") end end describe "special flags" do it "should generate PortCap" do expect(USPSFlags::Generate.svg("PortCap", outfile: "")).to include("PORTCAP") end it "should generate FleetCap" do expect(USPSFlags::Generate.svg("FleetCap", outfile: "")).to include("FLEETCAP") end it "should generate DAide" do expect(USPSFlags::Generate.svg("DAide", outfile: "")).to include("DAIDE") end it "should generate NAide" do expect(USPSFlags::Generate.svg("NAide", outfile: "")).to include("NAIDE") end it "should generate FLt" do expect(USPSFlags::Generate.svg("FLt", outfile: "")).to include("FLT") end it "should generate DFLt" do expect(USPSFlags::Generate.svg("DFLt", outfile: "")).to include("DFLT") end it "should generate NFLt" do expect(USPSFlags::Generate.svg("NFLt", outfile: "")).to include("NFLT") end end describe "pennants" do it "should generate the cruise pennant" do expect(USPSFlags::Generate.svg("Cruise", outfile: "")).to include("Cruise Pennant") end it "should generate the officer-in-charge pennant" do expect(USPSFlags::Generate.svg("OIC", outfile: "")).to include("Officer-in-Charge Pennant") end end describe "other flags" do it "should generate US" do expect(USPSFlags::Generate.svg("US", outfile: "")).to include("US Ensign") end it "should generate USPS Ensign" do expect(USPSFlags::Generate.svg("Ensign", outfile: "")).to include("USPS Ensign") end it "should generate the USPS Wheel logo" do expect(USPSFlags::Generate.svg("Wheel", outfile: "")).to include("USPS Ensign Wheel") end end describe "trident specifications" do it "should generate the trident specification sheet" do expect(USPSFlags::Generate.spec(outfile: "")).to include("USPS Trident Specifications") end end describe "png" do it "should raise PNGGenerationError without an outfile" do expect { USPSFlags::Generate.png(USPSFlags::Generate.svg("LtC", outfile: ""), outfile: "") }.to raise_error(USPSFlags::Errors::PNGGenerationError) end it "should not raise PNGGenerationError when correctly configured" do expect { USPSFlags::Generate.png(USPSFlags::Generate.svg("LtC", outfile: ""), outfile: "lib/output/PNG/LTC.png") }.to_not raise_error(USPSFlags::Errors::PNGGenerationError) end end describe "static files" do it "should raise USPSFlags::Errors::StaticFilesGenerationError when not given any true arguments" do expect { USPSFlags::Generate.all(svg: false, png: false, zips: false) }.to raise_error( USPSFlags::Errors::StaticFilesGenerationError, "At least one argument switch must be true out of [svg, png, zips]." ) end it "should not raise StaticFilesGenerationError while generating all static files" do expect { USPSFlags::Generate.all }.to_not raise_error(USPSFlags::Errors::StaticFilesGenerationError) end it "should raise USPSFlags::Errors::ZipGenerationError when not given any true arguments" do expect { USPSFlags::Generate.zips(svg: false, png: false) }.to raise_error( USPSFlags::Errors::ZipGenerationError, "At least one argument switch must be true out of [svg, png]." ) end it "should not raise ZipGenerationError while generating zip files" do expect { USPSFlags::Generate.zips }.to_not raise_error(USPSFlags::Errors::ZipGenerationError) end end end