Sha256: 8a5c469a3cb8b45d7fc81050b57ab4829b10181c462f730c5ea4e2a5617d50db
Contents?: true
Size: 1.81 KB
Versions: 20
Compression:
Stored size: 1.81 KB
Contents
# coding: utf-8 $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib') require 'onix' require 'stringio' context "ONIX::Writer" do before(:each) do @output = StringIO.new end specify "should output the correct xml metadata" do header = ONIX::Header.new writer = ONIX::Writer.new(@output, header) writer.end_document lines = @output.string.split("\n") # xml declaration lines[0][0,5].should eql("<?xml") # doctype lines[1][0,9].should eql("<!DOCTYPE") end specify "should output the correct xml metadata when used in block form" do header = ONIX::Header.new ONIX::Writer.open(@output, header) { |writer| } lines = @output.string.split("\n") # xml declaration lines[0][0,5].should eql("<?xml") # doctype lines[1][0,9].should eql("<!DOCTYPE") end specify "should output the header node" do header = ONIX::Header.new ONIX::Writer.open(@output, header) { |writer| } lines = @output.string.split("\n") lines[3][0,7].should eql("<Header") end specify "should output the product node" do header = ONIX::Header.new product = ONIX::Product.new ONIX::Writer.open(@output, header) do |writer| writer << product end lines = @output.string.split("\n") lines[4][0,8].should eql("<Product") end specify "should correctly store finished state" do header = ONIX::Header.new writer = ONIX::Writer.new(@output, header) writer.finished?.should be_false writer.end_document writer.finished?.should be_true end =begin specify "should convert non-ASCII chars to references when outputting as a string" do header = ONIX::Header.new header.from_person = "Hans Küng" ONIX::Writer.open(@output, header) { |writer| } @output.string.include?("Küng").should be_true end =end end
Version data entries
20 entries across 20 versions & 2 rubygems