Sha256: 2131f0fb7537cfbce6b72fb370745565e1c5a366d3058424f3d44a34faab7b6c

Contents?: true

Size: 1.25 KB

Versions: 15

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

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

  let(:xml) { File.read('./spec/fixtures/mdfe/lib/xml-mdfe.xml') }

  subject { described_class.new(xml) }

  before { File.delete(output_pdf) if File.exist?(output_pdf) }

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

  describe '#render_pdf' do
    it 'renders the mdfe' do
      expected = IO.binread("#{base_dir}mdfe.fixture.pdf")

      expect(subject.render_pdf).to eql expected
    end
  end

  describe '#save_pdf' do
    it 'saves the mdfe' do
      expect(File.exist?(output_pdf)).to be false

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

  context 'when MDF-e has multiple pages' do
    let(:xml) { File.read('./spec/fixtures/mdfe/lib/xml-mdfe-multiples-pages.xml') }

    it 'renders the header and the identification on each page' do
      expect(File.exist?(output_pdf)).to be false

      subject.save_pdf output_pdf
      expect("#{base_dir}mdfe-with-multiple-pages.pdf").to have_same_content_of file: output_pdf
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
br_danfe-1.2.1 spec/br_danfe/mdfe_spec.rb
br_danfe-1.2.0 spec/br_danfe/mdfe_spec.rb
br_danfe-1.1.0 spec/br_danfe/mdfe_spec.rb
br_danfe-1.0.0 spec/br_danfe/mdfe_spec.rb
br_danfe-0.20.0 spec/br_danfe/mdfe_spec.rb
br_danfe-0.19.0 spec/br_danfe/mdfe_spec.rb
br_danfe-0.18.0 spec/br_danfe/mdfe_spec.rb
br_danfe-0.17.8 spec/br_danfe/mdfe_spec.rb
br_danfe-0.17.7 spec/br_danfe/mdfe_spec.rb
br_danfe-0.17.6 spec/br_danfe/mdfe_spec.rb
br_danfe-0.17.5 spec/br_danfe/mdfe_spec.rb
br_danfe-0.17.4 spec/br_danfe/mdfe_spec.rb
br_danfe-0.17.3 spec/br_danfe/mdfe_spec.rb
br_danfe-0.17.2 spec/br_danfe/mdfe_spec.rb
br_danfe-0.17.1 spec/br_danfe/mdfe_spec.rb