Sha256: 94dd1ef2ec7da687100f17a37d0354c32031c40f88985dabe12c948d9abf47df

Contents?: true

Size: 1.9 KB

Versions: 4

Compression:

Stored size: 1.9 KB

Contents

# coding: utf-8

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

require 'onix'
require 'date'

context "ONIX::APAProduct" do

  before(:each) do
    @data_path = File.join(File.dirname(__FILE__),"..","data")
    file1    = File.join(@data_path, "product.xml")
    @doc = LibXML::XML::Document.file(file1)
    @product_node = @doc.root
  end

  specify "should provide read access to attibutes" do
    @product = ONIX::Product.from_xml(@product_node.to_s)
    @apa     = ONIX::APAProduct.new(@product)

    @apa.record_reference.should eql("365-9780194351898")
    @apa.notification_type.should eql(3)
    @apa.product_form.should eql("BC")
    @apa.number_of_pages.should eql(100)
    @apa.bic_main_subject.should eql("EB")
    @apa.publishing_status.should eql(4)
    @apa.publication_date.should eql(Date.civil(1998,9,1))
    @apa.pack_quantity.should eql(12)
  end

  specify "should provide write access to attibutes" do
    apa = ONIX::APAProduct.new

    apa.notification_type = 3
    apa.to_xml.to_s.include?("<NotificationType>03</NotificationType>").should be_true

    apa.record_reference = "365-9780194351898"
    apa.to_xml.to_s.include?("<RecordReference>365-9780194351898</RecordReference>").should be_true

    apa.product_form = "BC"
    apa.to_xml.to_s.include?("<ProductForm>BC</ProductForm>").should be_true

    apa.number_of_pages = 100
    apa.to_xml.to_s.include?("<NumberOfPages>100</NumberOfPages>").should be_true

    apa.bic_main_subject = "EB"
    apa.to_xml.to_s.include?("<BICMainSubject>EB</BICMainSubject>").should be_true

    apa.publishing_status = 4
    apa.to_xml.to_s.include?("<PublishingStatus>04</PublishingStatus>").should be_true

    apa.publication_date = Date.civil(1998,9,1)
    apa.to_xml.to_s.include?("<PublicationDate>19980901</PublicationDate>").should be_true

    apa.pack_quantity = 12
    apa.to_xml.to_s.include?("<PackQuantity>12</PackQuantity>").should be_true
  end

end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
milkfarm-onix-0.7.7 spec/apa_product_spec.rb
onix-0.7.8 spec/apa_product_spec.rb
onix-0.7.7 spec/apa_product_spec.rb
onix-0.7.6 spec/apa_product_spec.rb