Sha256: 5b7b52bd86201142a0c1c45676ac98590988e5f872108cbac1b11816c4fd51d4

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

# coding: utf-8

require 'spec_helper'

describe ONIX2::Stock do

  Given(:doc) { load_xml "stock.xml" }

  describe "should correctly convert to a string" do
    Given(:s) { ONIX2::Stock.from_xml(doc) }
    Then { s.to_xml.to_s.start_with? "<Stock>" }
  end

  describe "should provide read access to first level attributes" do
    Given(:s) { ONIX2::Stock.from_xml(doc) }

    # note that these fields *should* be numeric according to the ONIX spec,
    # however heaps of ONIX files in the wild have strings there.
    Then { s.on_hand == "2862" }
    Then { s.on_order == "0" }
  end

  context "should provide write access to first level attributes" do
    Given(:s) { ONIX2::Stock.new }
    describe :on_hand= do
      When { s.on_hand = "123" }
      Then { s.to_xml.to_s.include? "<OnHand>123</OnHand>" }
    end
    describe :on_order= do
      When { s.on_order = "011" }
      Then { s.to_xml.to_s.include? "<OnOrder>011</OnOrder>" }
    end
    describe :on_order= do
      When { s.on_order = 11 }
      Then { s.to_xml.to_s.include? "<OnOrder>11</OnOrder>" }
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
onix2-1.0.0 spec/stock_spec.rb