Sha256: 55c0877d4b2b9753f15866de2f0ce9984443aa9fc527e0511e707fc75feb43a0
Contents?: true
Size: 1.12 KB
Versions: 14
Compression:
Stored size: 1.12 KB
Contents
# coding: utf-8 require File.dirname(__FILE__) + '/spec_helper.rb' describe ONIX::Stock do before(:each) do data_path = File.join(File.dirname(__FILE__),"..","data") file1 = File.join(data_path, "stock.xml") @doc = Nokogiri::XML::Document.parse(File.read(file1)) @root = @doc.root end it "should correctly convert to a string" do s = ONIX::Stock.from_xml(@root.to_s) s.to_xml.to_s[0,7].should eql("<Stock>") end it "should provide read access to first level attributes" do s = ONIX::Stock.from_xml(@root.to_s) # note that these fields *should* be numeric according to the ONIX spec, # however heaps of ONIX files in the wild have strings there. s.on_hand.should eql("2862") s.on_order.should eql("0") end it "should provide write access to first level attributes" do s = ONIX::Stock.new s.on_hand = "123" s.to_xml.to_s.include?("<OnHand>123</OnHand>").should be_true s.on_order = "011" s.to_xml.to_s.include?("<OnOrder>011</OnOrder>").should be_true s.on_order = 11 s.to_xml.to_s.include?("<OnOrder>11</OnOrder>").should be_true end end
Version data entries
14 entries across 14 versions & 2 rubygems