Sha256: cfc0d615f311b0dea1b3ae07ff2bb26e29e7993cc60309d620a45d534e8023c7
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
require 'spec_helper' require 'crackr/xml' describe Crackr do let(:str) do <<-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 end let(:xml) do Nokogiri::XML str end describe '.parse' do context "when given an XML document" do it 'returns a hash' do Crackr::XML.parse(xml).should be_an_instance_of Hash end end context "when given a string representation of an XML document" do it 'returns a hash' do Crackr::XML.parse(str).should be_an_instance_of Hash end end it 'handles an only child' do Crackr::XML.parse(xml)['Title'].should eql 'Anti-Oedipus' end it 'handles arrays' do Crackr::XML.parse(xml)['Author'].should be_a Array end it 'handles attributes' do node = Crackr::XML.parse(xml)['Creator'] node['Role'].should eql 'Translator' node['__content__'].should eql 'Robert Hurley' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
crackr-1.0.0 | spec/crackr_spec.rb |