Sha256: 8f9e0a5ff228d829787e95e4ccc34f08bd1ff81dbfe7fbb5eb819a326911f816

Contents?: true

Size: 1.24 KB

Versions: 14

Compression:

Stored size: 1.24 KB

Contents

# coding: utf-8

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

describe ONIX::Contributor do

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

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

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

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

14 entries across 14 versions & 2 rubygems

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