Sha256: 6ef2364d7f656a7f87668ce2fe2cefa9ccd8f45025b2612ee63bc705fe7f8978

Contents?: true

Size: 1000 Bytes

Versions: 13

Compression:

Stored size: 1000 Bytes

Contents

# coding: utf-8

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

require 'onix'

context "ONIX::Price" do

  before(:each) do
    data_path = File.join(File.dirname(__FILE__),"..","data")
    file1    = File.join(data_path, "price.xml")
    @doc = LibXML::XML::Document.file(file1)
    @root = @doc.root
  end

  specify "should correctly convert to a string" do
    p = ONIX::Price.from_xml(@root.to_s)
    p.to_xml.to_s[0,7].should eql("<Price>")
  end

  specify "should provide read access to first level attibutes" do
    p = ONIX::Price.from_xml(@root.to_s)

    p.price_type_code.should eql(2)
    p.price_amount.should eql(BigDecimal.new("7.5"))
  end

  specify "should provide write access to first level attibutes" do
    p = ONIX::Price.new

    p.price_type_code = 1
    p.to_xml.to_s.include?("<PriceTypeCode>01</PriceTypeCode>").should be_true

    p.price_amount = BigDecimal.new("7.5")
    p.to_xml.to_s.include?("<PriceAmount>7.5</PriceAmount>").should be_true

  end

end

Version data entries

13 entries across 13 versions & 2 rubygems

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