Sha256: 326af7692bc8c0b0b391d9d2767acd27609851de9101db290712a487b75a39f4

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

# coding: utf-8

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

context "ONIX::Subject" do

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

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

  specify "should provide read access to first level attributes" do
    sub = ONIX::Subject.from_xml(@root.to_s)
    sub.subject_scheme_id.should eql(3)
    sub.subject_scheme_name.should eql("RBA Subjects")
    sub.subject_code.should eql("AABB")
  end

  specify "should provide write access to first level attributes" do
    sub = ONIX::Subject.new

    sub.subject_scheme_id = 2
    sub.to_xml.to_s.include?("<SubjectSchemeIdentifier>02</SubjectSchemeIdentifier>").should be_true

    sub.subject_code = "ABCD"
    sub.to_xml.to_s.include?("<SubjectCode>ABCD</SubjectCode>").should be_true

  end

end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
onix-0.8.4 spec/subject_spec.rb
milkfarm-onix-0.8.6 spec/subject_spec.rb
milkfarm-onix-0.8.5 spec/subject_spec.rb