Sha256: 3c5f62f9747657161e563d3fe19459e6d8ef0660bb5b49855a45c4751d0482db

Contents?: true

Size: 938 Bytes

Versions: 2

Compression:

Stored size: 938 Bytes

Contents

require 'spec_helper'

describe BrDanfe::DanfeNfce do
  let(:output_pdf) { "#{base_dir}output.pdf" }
  let(:base_dir) { './spec/fixtures/nfce/v4.00/' }
  let(:danfe) { BrDanfe::DanfeNfce.new(File.read("#{base_dir}nfce.xml")) }

  before do
    danfe.options.logo = 'spec/fixtures/logo.png'
    danfe.options.logo_dimensions = { width: 100, height: 100 }
  end

  describe '#render_pdf' do
    it 'renders the NFC-e pdf' do
      expected = IO.binread("#{base_dir}rendered_nfce.fixture.pdf")
      expect(danfe.render_pdf).to eq expected
    end
  end

  describe '#save_pdf' do
    before { File.delete(output_pdf) if File.exist?(output_pdf) }
    after { File.delete(output_pdf) if File.exist?(output_pdf) }

    it 'saves the NFC-e as pdf' do
      expect(File.exist?(output_pdf)).to be_falsey
      danfe.save_pdf output_pdf

      expect("#{base_dir}saved_nfce.fixture.pdf").to have_same_content_of file: output_pdf
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
br_danfe-0.12.1 spec/features/danfe_nfce_spec.rb
br_danfe-0.12.0 spec/features/danfe_nfce_spec.rb