Sha256: 74a84b49bd0f07b55dc6f425ffeb83debe7de16f7d6852e010035af1c2f79980

Contents?: true

Size: 1.06 KB

Versions: 13

Compression:

Stored size: 1.06 KB

Contents

# coding: utf-8

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

require 'onix'

context "ONIX::Subject" do

  before(:each) do
    data_path = File.join(File.dirname(__FILE__),"..","data")
    file1    = File.join(data_path, "subject.xml")
    @doc = LibXML::XML::Document.file(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 attibutes" 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 attibutes" 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

13 entries across 13 versions & 2 rubygems

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