[rspec-users] Submitting a Custom Matcher: gem or other method?

Ed Howland ed.howland at gmail.com
Sun Dec 27 15:03:55 EST 2009


Hi, I have a custom matcher that I call XMLDiff that takes an actual
XML string and an expected one and uses RSpec's normal line differ to
show the difference at the node level. It uses a method called
be_functionaly_eql, because two XML strings can be the same regardless
of whitespece. I.e. they are functionaly equivalent. If you ran both
through the same parser, they would (should) result in the same
behavior. So:

 actual_xml.should be_functionally_eql("<xmlstring ... >")

If they are not, you get a context diff right to the element level.
Useful for finding errors in long XML strings.

I have searched for such a thing to no avail. There may be other
solutions and I;d be interested in seeing them. But this is what I
came up with.

The question is, how would you recommend sharing it? I am new to
gem-ing, but can it be packaheged that way, or is there some other
method for sharing custom matchers? I can host it on Github, if that
is a recommended way to do so.

Thanks
Ed


-- 
Ed Howland
http://greenprogrammer.wordpress.com
http://twitter.com/ed_howland


More information about the rspec-users mailing list