Sha256: 8eef03d4e8db62f4f00bf30a24a459b8dfe37317c64ad467bb1c4c0396f431fc

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

# coding: utf-8

require 'spec_helper'

describe ONIX2::Contributor do

  Given(:doc) { load_xml "contributor.xml" }

  describe "should correctly convert to a string" do
    Given(:header) { ONIX2::Contributor.from_xml(doc) }
    Then { header.to_xml.to_s.start_with? "<Contributor>" }
  end

  describe "should provide read access to first level attributes" do
    Given(:contrib) { ONIX2::Contributor.from_xml(doc) }

    Then { contrib.contributor_role == "A01" }
    Then { contrib.person_name_inverted == "SHAPIRO" }
    Then { contrib.sequence_number == 1 }
  end

  context "should provide write access to first level attributes" do
    Given(:contrib) { ONIX2::Contributor.new }
    describe :contributor_role= do
      When { contrib.contributor_role = "A02" }
      Then { contrib.to_xml.to_s.include? "<ContributorRole>A02</ContributorRole>" }
    end
    describe :person_name_inverted= do
      When { contrib.person_name_inverted = "Healy, James" }
      Then { contrib.to_xml.to_s.include? "<PersonNameInverted>Healy, James</PersonNameInverted>" }
    end
    describe :sequence_number= do
      When { contrib.sequence_number = 1 }
      Then { contrib.to_xml.to_s.include? "<SequenceNumber>1</SequenceNumber>" }
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
onix2-1.0.0 spec/contributor_spec.rb