# Gem xmlsimple behaves unexplectedly after adding aws-s3 gem

**URL:** <https://www.ruby-forum.com/t/gem-xmlsimple-behaves-unexplectedly-after-adding-aws-s3-gem/181157>\
**Category:** Rails\
**Created:** [January 6, 2010, 3:42pm UTC](https://www.ruby-forum.com/t/gem-xmlsimple-behaves-unexplectedly-after-adding-aws-s3-gem/181157 "2010-01-06T15:42:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 6, 2010, 3:42pm UTC](https://www.ruby-forum.com/t/gem-xmlsimple-behaves-unexplectedly-after-adding-aws-s3-gem/181157/1 "2010-01-06T15:42:21Z")

</div>

Hi all,  
after spending a long night trying to track down some unexpected spec  
failures in my app I came to the conclusion that the reason was aws-s3  
gem, which probably monkey patches XmlSimple class and changes its  
behaviour so that xml\_in method won’t honor passed options anymore.  
Here is a simple spec file to prove it… uncomment line 4 to make it  
fail.

require ‘rubygems’  
require ‘spec’  
require ‘xmlsimple’

# require ‘aws/s3’

module XmlSimpleHelper  
def xml\_sample  
%q(  
  
Ciao  
Hello  
  
)  
end  
end

describe XmlSimple do  
include XmlSimpleHelper  
it ‘should remove root tag by default’ do  
expected = {‘greeting’ =\> [“Ciao”, “Hello”]}  
XmlSimple.xml\_in(xml\_sample).should == expected  
end

it ‘should keep root tag when asked’ do  
options = {‘KeepRoot’ =\> true}  
expected = {‘greetings’ =\> [{‘greeting’ =\> [“Ciao”, “Hello”]}]}  
XmlSimple.xml\_in(xml\_sample, options).should == expected  
end

it ‘should force to array when asked’ do  
options = {‘ForceArray’ =\> true}  
expected = {‘greeting’ =\> [“Ciao”, “Hello”]}  
XmlSimple.xml\_in(xml\_sample, options).should == expected  
end  
end

All gems were freshly updated… I haven’l looked at aws-s3 code yet,  
I will do later, in the meanwhile I’d like to know other people  
opinion, if this is some kind of bug in the gem or what…

TIA

Andrea L.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 6, 2010, 6:16pm UTC](https://www.ruby-forum.com/t/gem-xmlsimple-behaves-unexplectedly-after-adding-aws-s3-gem/181157/2 "2010-01-06T18:16:53Z")

</div>

Again, the aws-s3 gem keeps biting my hand:

require ‘rubygems’  
require ‘spec’  
require ‘xmlsimple’  
require ‘aws/s3’ # remove to test pass

def xml  
%q(10.99)  
end

def expected  
{“content”=\>“10.99”, “currency”=\>“USD”}  
end

describe XmlSimple do  
it ‘should return expected content’ do  
data = XmlSimple.xml\_in(xml, ‘keeproot’ =\> false)  
data.should == expected  
end  
end
