From: Ed Howland Date: 2009-12-27T08:05:27+09:00 Subject: Re: [ANN] Ruby 1.8.7-p248 released. Also, I hate to be nit picky about this, but can the REXML::docu,emt$stand_alone? predicate return true for "yes" and false for "no". At the moment it returns the string value of the xml declaation attribute. If the intent is to report the value as a string as the documentation suggests, then the method should just be named 'standalone' or 'stand_alone' if you wish. More like version and encoding. Appending the '?' makes it look like a predicate. This fails to work in unit testing and cases like RSpec. doc = REXML::Document.new('') doc.should_not be_stand_alone produces 1) 'REXML::Document should not be stand_alone' FAILED expected stand_alone? to return false, got "no" Note, a DSL custom matcher is easily written. (I have changed the predicate to standalone? to avoid confusion, and because IMO, it shoud be named like the attribute it self, and who wants to look at the documentation to have to figure out why it isn't just named like the other attributes.) pec::Matchers.define :be_standalone do |expected| match do |actual| actual.stand_alone? == 'yes' end failure_message_for_should do |actual| "expected that #{actual}.stand_alone? should == 'yes'" end failure_message_for_should_not do |actual| "expected that #{actual}.stand_alone? should == 'no'" end description do "be a standalone document" end end Merry Christmas! Ed [1] XML Spec:standalone http://www.w3.org/TR/REC-xml/#sec-rmd -- Ed Howland http://greenprogrammer.wordpress.com http://twitter.com/ed_howland