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.