Sha256: 1f653db2d9577a6e042696b576a719700994a8903dede66ff62cc2e7231b9540

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

# coding: utf-8

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

describe ONIX::WorkIdentifier do

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

  it "should correctly convert to a string" do
    t = ONIX::WorkIdentifier.from_xml(@root.to_s)
    t.to_xml.to_s[0,16].should eql("<WorkIdentifier>")
  end

  it "should provide read access to first level attributes" do
    t = ONIX::WorkIdentifier.from_xml(@root.to_s)
    t.work_id_type.should eql(1)
    t.id_type_name.should eql("Proprietary Publisher Scheme")
    t.id_value.should eql("ABC123")
  end

  it "should provide write access to first level attributes" do
    t = ONIX::WorkIdentifier.new

    t.work_id_type = 1
    t.to_xml.to_s.include?("<WorkIDType>01</WorkIDType>").should be_true

    t.id_type_name = "Proprietary Publisher Scheme"
    t.to_xml.to_s.include?("<IDTypeName>Proprietary Publisher Scheme</IDTypeName>").should be_true

    t.id_value = "ABC123"
    t.to_xml.to_s.include?("<IDValue>ABC123</IDValue>").should be_true
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
milkfarm-onix-0.8.8 spec/work_identifier_spec.rb
milkfarm-onix-0.8.7 spec/work_identifier_spec.rb