Sha256: 02d7ae15c81c4c293d2c5a65be2e0779607d40afb11c7793ba04618cb52ca9f3

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

# coding: utf-8

require File.dirname(__FILE__) + '/spec_helper.rb'

context "ONIX::Publisher" do

  before(:each) do
    data_path = File.join(File.dirname(__FILE__),"..","data")
    file1    = File.join(data_path, "publisher.xml")
    @doc     = Nokogiri::XML::Document.parse(File.read(file1))
    @root = @doc.root
  end

  specify "should correctly convert to a string" do
    pub = ONIX::Publisher.from_xml(@root.to_s)
    pub.to_xml.to_s[0,11].should eql("<Publisher>")
  end

  specify "should provide read access to first level attibutes" do
    pub = ONIX::Publisher.from_xml(@root.to_s)
    pub.publishing_role.should eql(1)
    pub.publisher_name.should eql("Desbooks Publishing")
  end

  specify "should provide write access to first level attibutes" do
    pub = ONIX::Publisher.new

    pub.publisher_name = "Paulist Press"
    pub.to_xml.to_s.include?("<PublisherName>Paulist Press</PublisherName>").should be_true

    pub.publishing_role = 2
    pub.to_xml.to_s.include?("<PublishingRole>02</PublishingRole>").should be_true
  end

end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
onix-0.8.3 spec/publisher_spec.rb
milkfarm-onix-0.8.3 spec/publisher_spec.rb
onix-0.8.2 spec/publisher_spec.rb
onix-0.8.1 spec/publisher_spec.rb
onix-0.8.0 spec/publisher_spec.rb