# coding: utf-8 require 'spec_helper' describe ActiveExport::Xml do before { ActiveExport.configure do |config| config.sources = { xml: fixture_file('xml.yml') } end } let(:author_1) { Author.create!(name: 'author_1') } let(:author_2) { Author.create!(name: 'author_2') } let!(:book_1) { Book.create!(name: 'book_1', author: author_1, price: 58) } let!(:book_2) { Book.create!(name: 'book_2', author: author_2, price: 38) } let(:expect_string) { <<-EOS book_1 author_1 63.51 book_2 author_2 41.61 EOS } describe ".export" do subject { ActiveExport::Xml.export(Book.scoped, :xml, :book_1) } it { should == expect_string } end describe ".export_file" do let(:xml_file) { Rails.root.join('tmp', 'test.xml') } before { FileUtils.rm yaml_file if FileTest.exist?(xml_file) ActiveExport::Xml.export_file(Book.scoped, :xml, :book_1, xml_file) } after { FileUtils.rm xml_file if FileTest.exist?(xml_file) } it { File.read(xml_file).should == expect_string } end end