Sha256: 186f5fb724eb32d3092235dcf5f85481f3dc1016db832cbe7e07cbb8cd0c5859
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
# 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 <?xml version="1.0" encoding="UTF-8"?> <records> <book> <name>book_1</name> <author_name>author_1</author_name> <price>63.51</price> </book> <book> <name>book_2</name> <author_name>author_2</author_name> <price>41.61</price> </book> </records> 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
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_export-0.4.0 | spec/active_export/xml_spec.rb |
active_export-0.3.0 | spec/active_export/xml_spec.rb |