Sha256: 680cb6c8b181eb15c7eae093f7972b0cb4c1a35a516a4aba6887bd44fd372929

Contents?: true

Size: 1.02 KB

Versions: 14

Compression:

Stored size: 1.02 KB

Contents

# coding: utf-8

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

describe 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

  it "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

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

  it "should provide write access to first level attributes" 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

14 entries across 14 versions & 2 rubygems

Version Path
onix-0.9.5 spec/publisher_spec.rb
onix-0.9.4 spec/publisher_spec.rb
milkfarm-onix-0.8.13 spec/publisher_spec.rb
milkfarm-onix-0.8.12 spec/publisher_spec.rb
onix-0.9.3 spec/publisher_spec.rb
onix-0.9.2 spec/publisher_spec.rb
onix-0.9.1 spec/publisher_spec.rb
milkfarm-onix-0.8.11 spec/publisher_spec.rb
milkfarm-onix-0.8.10 spec/publisher_spec.rb
onix-0.9.0 spec/publisher_spec.rb
milkfarm-onix-0.8.9 spec/publisher_spec.rb
milkfarm-onix-0.8.8 spec/publisher_spec.rb
milkfarm-onix-0.8.7 spec/publisher_spec.rb
onix-0.8.5 spec/publisher_spec.rb