Sha256: c96d2241155d364b17e89a5e3ed39b7dbdf55f78fffeca7b4c46402b209a6b8b

Contents?: true

Size: 1.01 KB

Versions: 10

Compression:

Stored size: 1.01 KB

Contents

# coding: utf-8

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

describe ONIX::ProductIdentifier do

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

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

  it "should provide read access to first level attributes" do
    id = ONIX::ProductIdentifier.from_xml(@root.to_s)

    id.product_id_type.should eql(2)
    id.id_value.should eql("0858198363")
  end

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

    id.product_id_type = 2
    id.to_xml.to_s.include?("<ProductIDType>02</ProductIDType>").should be_true

    id.id_value = "James"
    id.to_xml.to_s.include?("<IDValue>James</IDValue>").should be_true

  end

end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
onix-0.9.5 spec/product_identifier_spec.rb
onix-0.9.4 spec/product_identifier_spec.rb
onix-0.9.3 spec/product_identifier_spec.rb
onix-0.9.2 spec/product_identifier_spec.rb
onix-0.9.1 spec/product_identifier_spec.rb
onix-0.9.0 spec/product_identifier_spec.rb
milkfarm-onix-0.8.9 spec/product_identifier_spec.rb
milkfarm-onix-0.8.8 spec/product_identifier_spec.rb
milkfarm-onix-0.8.7 spec/product_identifier_spec.rb
onix-0.8.5 spec/product_identifier_spec.rb