Sha256: 07015d1b918bf5a6472139f60166cee3601ff45daaf0c347a9d61e856820f79c
Contents?: true
Size: 972 Bytes
Versions: 1
Compression:
Stored size: 972 Bytes
Contents
require 'spec_helper' module AmazonProduct describe Builder 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 Builder.from_xml(xml).should be_an_instance_of Hash end it 'handles only childs' do Builder.from_xml(xml)['Title'].should eql 'Anti-Oedipus' end it 'handles arrays' do Builder.from_xml(xml)['Author'].should be_a Array end it 'handles attributes' do node = Builder.from_xml(xml)['Creator'] node['Role'].should eql 'Translator' node['__content__'].should eql 'Robert Hurley' end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
amazon_product-3.0.1 | spec/amazon_product/builder_spec.rb |