require 'spec_helper' describe BrDanfe::DanfeLib::Vol do let(:base_dir) { './spec/fixtures/nfe/lib/' } let(:output_pdf) { "#{base_dir}output.pdf" } let(:pdf) { BrDanfe::DanfeLib::Document.new } let(:xml) { BrDanfe::DanfeLib::XML.new(xml_as_string) } subject { described_class.new(pdf, xml) } describe '#render' do let(:xml_as_string) do <<-eos 1 VOLUMES 1 DIVERSOS 1 1 1000.000 1100.000 2 VOLUMES 2 DIVERSOS 2 2 2000.000 2200.000 3 VOLUMES 3 DIVERSOS 3 3 3000.000 3300.000 eos end before do subject.render File.delete(output_pdf) if File.exist?(output_pdf) end it 'renders xml to the pdf' do expect(File.exist?(output_pdf)).to be_falsey pdf.render_file output_pdf expect("#{base_dir}vol#render.pdf").to have_same_content_of file: output_pdf end it 'returns the quantity of volumes' do expect(subject.render).to eq 3 end context 'when any tag is found' do let(:xml_as_string) do <<-eos eos end it 'renders blank boxes' do expect(File.exist?(output_pdf)).to be_falsey pdf.render_file output_pdf expect("#{base_dir}vol#render-blank-boxes.pdf").to have_same_content_of file: output_pdf end end end end