Sha256: e6ff3b7d3afb8f14e124b643e96c7bdf0f1df0addf128c18dfacefeafad03332

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'

describe BrDanfe::Danfe do
  let(:xml) do
    <<-eos
      <nfeProc>
        <NFe>
          <infNFe>
            <ide>
              <mod>#{mod}</mod>
              <NFref>
                <refNFP>
                  <mod>04</mod>
                </refNFP>
              </NFref>
            </ide>
          </infNFe>
        </NFe>
      </nfeProc>
    eos
  end

  subject { described_class.new(xml) }

  context 'xmls parameter' do
    let(:mod) { 55 }

    it 'accepts one xml' do
      subject = described_class.new(xml)

      expect(subject.class).to eq BrDanfe::DanfeLib::Nfe
    end

    it 'accepts an array of xmls' do
      subject = described_class.new([xml, xml])

      expect(subject.class).to eq BrDanfe::DanfeLib::Nfe
    end
  end

  context 'when the xml document type is NF-e' do
    let(:mod) { 55 }

    it 'returns a NF-e danfe class' do
      expect(subject.class).to eq BrDanfe::DanfeLib::Nfe
    end
  end

  context 'when the xml document type is NFC-e' do
    let(:mod) { 65 }

    it 'returns a NFC-e danfe class' do
      expect(subject.class).to eq BrDanfe::DanfeLib::Nfce
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
br_danfe-0.17.0 spec/br_danfe/danfe_spec.rb
br_danfe-0.16.0 spec/br_danfe/danfe_spec.rb
br_danfe-0.15.1 spec/br_danfe/danfe_spec.rb
br_danfe-0.15.0 spec/br_danfe/danfe_spec.rb