Sha256: 330dbbca4dbd31cec93124cfa873b9ce5256dba03b44c0a9eff6a9fe3ec915d0
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
# coding: utf-8 require 'spec_helper' describe ONIX2::Price do Given(:doc) { load_xml "price.xml" } describe "should correctly convert to a string" do Given(:p) { ONIX2::Price.from_xml(doc) } Then { p.to_xml.to_s.start_with? "<Price>" } end describe "should provide read access to first level attributes" do Given(:p) { ONIX2::Price.from_xml(doc) } Then { p.price_type_code == 2 } Then { p.price_amount == BigDecimal.new("7.5") } Then { p.discount_percent == 0.4 } end context "should provide write access to first level attributes" do Given(:p) { ONIX2::Price.new } describe :price_type_code= do When { p.price_type_code = 1 } Then { p.to_xml.to_s.include? "<PriceTypeCode>01</PriceTypeCode>" } end describe :price_amount= do When { p.price_amount = BigDecimal.new("7.5") } Then { p.to_xml.to_s.include? "<PriceAmount>7.5</PriceAmount>" } end end describe "should provide read access to discount_coded IDs" do Given(:p) { ONIX2::Price.from_xml(doc) } Then { p.discounts_coded.size == 2 } end context "should provide write access to discount_coded IDs" do Given(:discount_coded1) { ONIX2::DiscountCoded.new(discount_code_type: 1) } Given(:discount_coded2) { ONIX2::DiscountCoded.new(discount_code: "code2") } Given(:p) { ONIX2::Price.new } describe :series_identifiers= do When { p.discounts_coded = [discount_coded1, discount_coded2] } Then { p.to_xml.to_s.include? "<DiscountCodeType>01</DiscountCodeType>" } Then { p.to_xml.to_s.include? "<DiscountCode>code2</DiscountCode>" } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
onix2-1.0.0 | spec/price_spec.rb |