You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Marshalling or unmarshalling an XML document using ROXML is freezing nil.
I have included a failing spec that demonstrates the issue and a copy of the Gemfile and rvm config that was used to run the spec.
frozen_nil_spec.rb
require'rubygems'require'roxml'describe'roxml'dolet(:xml_file){File.open(File.expand_path('library.xml',File.dirname(__FILE__)))}context'before unmarshalling an XML document'doit{nil.should_notbe_frozen}endcontext'after unmarshalling an XML document'dobeforedolib=Library.from_xml(xml_file)endit{nil.should_notbe_frozen}endendclassBookincludeROXMLxml_accessor:isbn,:from=>"@ISBN"# attribute with name 'ISBN'xml_accessor:titlexml_accessor:description,:cdata=>true# text node with cdata protectionxml_accessor:authorendclassLibraryincludeROXMLxml_accessor:name,:from=>"NAME",:cdata=>truexml_accessor:books,:as=>[Book]# by default roxml searches for books for in <book> child nodes, then, if none are present, in ./books/book childrenend
rspec output
.F
Failures:
1) roxml after unmarshalling an XML document
Failure/Error: it { nil.should_not be_frozen }
expected frozen? to return false, got true
# ./spec/frozen_nil_spec.rb:16:in `block (3 levels) in <top (required)>'
Finished in 0.00151 seconds
2 examples, 1 failure
Failed examples:
rspec ./spec/frozen_nil_spec.rb:16 # roxml after unmarshalling an XML document
library.xml
<?xml version="1.0"?>
<library>
<NAME><![CDATA[Favorite Books]]></NAME>
<bookISBN="0201710897">
<title>The PickAxe</title>
<description><![CDATA[Best Ruby book out there!]]></description>
<author>David Thomas, Andrew Hunt, Dave Thomas</author>
</book>
</library>
Thanks Warner for the great bug report. I believe I have this fixed, and have it released as 3.2.1. The problem in this case was related to overzealous freezing of the roxml_naming_convention attribute, which is sometimes nil. In hindsight I don't really see the point in freezing it so I've dropped that altogether.
Now I have some questions about the freezing behavior in roxml (i.e. when one supplies the :frozen option to an attribute) and whether they can lead to similar behavior, so I've tried to diminish those possibilities, but they still are present I believe.
Marshalling or unmarshalling an XML document using ROXML is freezing nil.
I have included a failing spec that demonstrates the issue and a copy of the Gemfile and rvm config that was used to run the spec.
frozen_nil_spec.rb
rspec output
library.xml
Gemfile
Gemfile.lock
.rvmrc
The text was updated successfully, but these errors were encountered: