require 'spec_helper' describe BrDanfe::MdfeLib::FiscoControl do let(:base_dir) { './spec/fixtures/mdfe/lib/' } let(:output_pdf) { "#{base_dir}output.pdf" } let(:xml_as_string) do <<~XML 32210717781119000141580010000001211000000003 XML end let(:pdf) { BrDanfe::MdfeLib::Document.new } let(:xml) { BrDanfe::XML.new(xml_as_string) } subject { described_class.new(pdf, xml) } let(:pdf_text) do PDF::Inspector::Text.analyze(pdf.render).strings.join("\n") end describe '#generate' do after { File.delete(output_pdf) if File.exist?(output_pdf) } it 'generates the title' do title = 'CONTROLE DO FISCO' subject.generate expect(pdf_text).to include title end it 'generates the bar code' do expect(File.exist?(output_pdf)).to be false subject.generate pdf.render_file output_pdf expect("#{base_dir}fisco_control#barcode.pdf").to have_same_content_of file: output_pdf end it 'generates the nfe key' do nfe_key = "Chave de Acesso\n32210717781119000141580010000001211000000003" subject.generate expect(pdf_text).to include nfe_key end end end