Sha256: d469ff46e331ee70618830fd16829e84bc6995f419922054801578c61853b267
Contents?: true
Size: 992 Bytes
Versions: 2
Compression:
Stored size: 992 Bytes
Contents
require 'spec_helper' module AmazonProduct describe HashBuilder do let(:xml) do xml = <<-XML.gsub!(/>\s+</, '><').strip! <?xml version=\"1.0\" ?> <ItemAttributes> <Title>Anti-Oedipus</Title> <Author>Gilles Deleuze</Author> <Author>Felix Guattari</Author> <Creator Role="Translator">Robert Hurley</Creator> </ItemAttributes> XML Nokogiri::XML(xml) end describe '.from_xml' do it 'returns a hash' do HashBuilder.from_xml(xml).should be_an_instance_of Hash end it 'handles only childs' do HashBuilder.from_xml(xml)['Title'].should eql 'Anti-Oedipus' end it 'handles arrays' do HashBuilder.from_xml(xml)['Author'].should be_a Array end it 'handles attributes' do node = HashBuilder.from_xml(xml)['Creator'] node['Role'].should eql 'Translator' node['__content__'].should eql 'Robert Hurley' end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
amazon_product-3.0.0.pre.2 | spec/amazon_product/hash_builder_spec.rb |
amazon_product-3.0.0.pre.1 | spec/amazon_product/hash_builder_spec.rb |