Sha256: dd83ef894c4a8adbeca334270a96b79ff5f7483d5b333db8811193ff78816076

Contents?: true

Size: 1.13 KB

Versions: 13

Compression:

Stored size: 1.13 KB

Contents

# coding: utf-8

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

require 'onix'

context "ONIX::Stock" do

  before(:each) do
    data_path = File.join(File.dirname(__FILE__),"..","data")
    file1    = File.join(data_path, "stock.xml")
    @doc = LibXML::XML::Document.file(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

13 entries across 13 versions & 2 rubygems

Version Path
milkfarm-onix-0.7.7 spec/stock_spec.rb
onix-0.7.8 spec/stock_spec.rb
onix-0.7.7 spec/stock_spec.rb
onix-0.7.6 spec/stock_spec.rb
onix-0.7.5 spec/stock_spec.rb
onix-0.7.4 spec/stock_spec.rb
onix-0.7.2 spec/stock_spec.rb
onix-0.7.3 spec/stock_spec.rb
onix-0.7.0 spec/stock_spec.rb
onix-0.7.1 spec/stock_spec.rb
onix-0.5.0 spec/stock_spec.rb
onix-0.6.0 spec/stock_spec.rb
onix-0.5.1 spec/stock_spec.rb