Sha256: ab3fb126d23d8926bf61bc39f0cd229e946a70b78631a09d4372426f508def23

Contents?: true

Size: 1.26 KB

Versions: 13

Compression:

Stored size: 1.26 KB

Contents

# coding: utf-8

$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')

require 'onix'

context "ONIX::Contributor" do

  before(:each) do
    data_path = File.join(File.dirname(__FILE__),"..","data")
    file1    = File.join(data_path, "contributor.xml")
    @doc = LibXML::XML::Document.file(file1)
    @root = @doc.root
  end

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

  specify "should provide read access to first level attibutes" do
    contrib = ONIX::Contributor.from_xml(@root.to_s)

    contrib.contributor_role.should eql("A01")
    contrib.person_name_inverted.should eql("SHAPIRO")
    contrib.sequence_number.should eql(1)
  end

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

    contrib.contributor_role = "A02"
    contrib.to_xml.to_s.include?("<ContributorRole>A02</ContributorRole>").should be_true

    contrib.person_name_inverted = "Healy, James"
    contrib.to_xml.to_s.include?("<PersonNameInverted>Healy, James</PersonNameInverted>").should be_true

    contrib.sequence_number = 1
    contrib.to_xml.to_s.include?("<SequenceNumber>1</SequenceNumber>").should be_true
  end

end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
milkfarm-onix-0.7.7 spec/contributor_spec.rb
onix-0.7.8 spec/contributor_spec.rb
onix-0.7.7 spec/contributor_spec.rb
onix-0.7.6 spec/contributor_spec.rb
onix-0.7.5 spec/contributor_spec.rb
onix-0.7.4 spec/contributor_spec.rb
onix-0.7.2 spec/contributor_spec.rb
onix-0.7.3 spec/contributor_spec.rb
onix-0.7.0 spec/contributor_spec.rb
onix-0.7.1 spec/contributor_spec.rb
onix-0.5.1 spec/contributor_spec.rb
onix-0.6.0 spec/contributor_spec.rb
onix-0.5.0 spec/contributor_spec.rb