Sha256: 04f5764e6f3536b1da15e0561f882e6dbdc2653dd5443794fd627270b2a5d7d0
Contents?: true
Size: 1.13 KB
Versions: 5
Compression:
Stored size: 1.13 KB
Contents
# coding: utf-8 require File.dirname(__FILE__) + '/spec_helper.rb' context "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 specify "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 specify "should provide read access to first level attibutes" 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 specify "should provide write access to first level attibutes" 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
5 entries across 5 versions & 2 rubygems
Version | Path |
---|---|
onix-0.8.3 | spec/stock_spec.rb |
milkfarm-onix-0.8.3 | spec/stock_spec.rb |
onix-0.8.2 | spec/stock_spec.rb |
onix-0.8.1 | spec/stock_spec.rb |
onix-0.8.0 | spec/stock_spec.rb |