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

Ed Howland ed.howland at gmail.com
Mon Dec 28 14:49:24 EST 2009

On Mon, Dec 28, 2009 at 11:27 AM, David Chelimsky <dchelimsky at gmail.com> wrote:
> On Sun, Dec 27, 2009 at 2:03 PM, Ed Howland <ed.howland at gmail.com> wrote:
>> 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.
> For most users, gems are the easiest answer. By all means, host source on
> github if you want people to contribute, or have a place to inspect code,
> but you don't need a public source repository in order to push gems to
> gemcutter.
> HTH,

Yes it does. That was my plan, to add a gem to my github account. I'll
search out other DSLs for RSpec and see how they packaged them as a
gem. I imagine the easiest way to use it is to add the require to
spec_helper.rb (assuming you have one) and then call the
be_functionally_eql in your specs as normal.


And Happy New Year!

> David
>> Thanks
>> Ed
>> --
>> Ed Howland
>> http://greenprogrammer.wordpress.com
>> http://twitter.com/ed_howland
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

Ed Howland

More information about the rspec-users mailing list