andrea longhi
2010-Jan-06  14:13 UTC
gem xmlsimple behaves unexplectedly after adding aws-s3 gem
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(
      <greetings>
        <greeting>Ciao</greeting>
        <greeting>Hello</greeting>
      </greetings>
    )
  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 Longhi
-- 
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
andrea longhi
2010-Jan-06  17:15 UTC
Re: gem xmlsimple behaves unexplectedly after adding aws-s3 gem
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(<price currency="USD">10.99</price>)
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
-- 
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.