Sha256: dc5c294518ec33bcb5ac5c425f81a3a9a6257d4d7d17882fb4a5e5336b1efbae

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

require 'spec_helper'

describe BrDanfe::MdfeLib::Totalizer do
  let(:xml_as_string) do
    <<~XML
      <?xml version="1.0" encoding="UTF-8"?>
      <mdfeProc xmlns="http://www.portalfiscal.inf.br/mdfe" versao="3.00">
      	<MDFe xmlns="http://www.portalfiscal.inf.br/mdfe">
      		<infMDFe Id="MDFe32210717781119000141580010000001211000000003" versao="3.00">
            <tot>
      				<qNFe>10</qNFe>
      				<vCarga>8222.10</vCarga>
      				<cUnid>01</cUnid>
      				<qCarga>615.1400</qCarga>
      			</tot>
      		</infMDFe>
      	</MDFe>
      </mdfeProc>
    XML
  end

  let(:pdf) { BrDanfe::MdfeLib::Document.new }
  let(:xml) { BrDanfe::XML.new(xml_as_string) }

  let(:base_dir) { './spec/fixtures/mdfe/lib/' }
  let(:output_pdf) { "#{base_dir}output.pdf" }

  subject { described_class.new(pdf, xml) }

  let(:pdf_text) do
    PDF::Inspector::Text.analyze(pdf.render).strings.join("\n")
  end

  describe '#generate' do
    it 'generates the nfe quantity' do
      nfe_quantity = "QTD. NFe\n10"

      subject.generate
      expect(pdf_text).to include nfe_quantity
    end

    it 'generates only the box of cte quantity' do
      cte_quantity = "QTD. CTe\n"

      subject.generate
      expect(pdf_text).to include cte_quantity
    end

    it 'generates the total weight' do
      total_weight = "Peso total (Kg)\n615,14"

      subject.generate
      expect(pdf_text).to include total_weight
    end

    it'generates the totalizer title' do
      title = 'Modelo Rodoviário de Carga'

      subject.generate
      expect(pdf_text).to include title
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
br_danfe-0.17.0 spec/br_danfe/mdfe_lib/totalizer_spec.rb
br_danfe-0.16.0 spec/br_danfe/mdfe_lib/totalizer_spec.rb