require "spec_helper" describe BrDanfe::Vol do let(:base_dir) { "./spec/fixtures/lib/"} let(:output_pdf) { "#{base_dir}output.pdf" } let(:pdf) { BrDanfe::Document.new } let(:xml) { BrDanfe::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 be_same_file_as(output_pdf) end it "returns the quantity of volumes" do expect(subject.render).to eq 3 end end end