Ed Howland
2009-Dec-27 20:03 UTC
[rspec-users] Submitting a Custom Matcher: gem or other method?
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
David Chelimsky
2009-Dec-28 16:27 UTC
[rspec-users] Submitting a Custom Matcher: gem or other method?
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, 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 >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20091228/22a138b9/attachment.html>
Ed Howland
2009-Dec-28 19:49 UTC
[rspec-users] Submitting a Custom Matcher: gem or other method?
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. Thanks, And Happy New Year! Ed> 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 http://greenprogrammer.wordpress.com http://twitter.com/ed_howland
Ashley Moran
2009-Dec-29 10:28 UTC
[rspec-users] Submitting a Custom Matcher: gem or other method?
On 28 Dec 2009, at 16:27, David Chelimsky wrote:> 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.A standard location for RSpec matchers would be pretty handy though, WDYT? -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran
David Chelimsky
2009-Dec-29 15:09 UTC
[rspec-users] Submitting a Custom Matcher: gem or other method?
On Tue, Dec 29, 2009 at 4:28 AM, Ashley Moran <ashley.moran at patchspace.co.uk> wrote:> > On 28 Dec 2009, at 16:27, David Chelimsky wrote: > > > 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. > > A standard location for RSpec matchers would be pretty handy though, WDYT? >First, I have no cycles to start setting something up like this for a while now. I''m trying to wrap up the loose ends on the book and get it to production. After that, any spare time I have is going to be devoted to getting the rspec-2.0 and rspec-rails-2.0 (for rails-3.0) projects rolling in earnest. That said, I definitely think we need a home for information about matchers. Hosting them, however, is something I''d rather leave to the professionals :) I''ve imagined a website where folks can list info about matcher libraries and others can comment and possibly vote on them. If anybody wants to volunteer to drive this in the short run, that would be great, but I won''t be able to do it myself for several months. Cheers, David -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20091229/c28ecf18/attachment.html>
Ed Howland
2009-Dec-29 15:53 UTC
[rspec-users] Submitting a Custom Matcher: gem or other method?
On Tue, Dec 29, 2009 at 10:09 AM, David Chelimsky <dchelimsky at gmail.com> wrote:> On Tue, Dec 29, 2009 at 4:28 AM, Ashley Moran > <ashley.moran at patchspace.co.uk> wrote: >> >> On 28 Dec 2009, at 16:27, David Chelimsky wrote: >> > First, I have no cycles to start setting something up like this for a while > now. I''m trying to wrap up the loose ends on the book and get it to > production. After that, any spare time I have is going to be devoted to > getting the rspec-2.0 and rspec-rails-2.0 (for rails-3.0) projects rolling > in earnest.Good luck on the book. I am eager to buy it!> That said,?I definitely think we need a home for information about matchers. > Hosting them, however, is something I''d rather leave to the professionals :) > I''ve imagined a website where folks can list info about matcher libraries > and others can comment and possibly vote on them. If anybody wants to > volunteer to drive this in the short run, that would be great, but I won''t > be able to do it myself for several months. > Cheers, > DavidJust a suggestion, several other projects have contributions listed on their Git hub wiki. Can we create a page for them, linking to other Github accounts. I don''t knoe about voting and such, but it might be a start. The rspec.info page can just link to the Github wiki for a user submitted contributions page and people can go from there. Thereby offloading the responsibility. If I can help help in any way, let me know. Ed -- Ed Howland http://greenprogrammer.wordpress.com http://twitter.com/ed_howland
David Chelimsky
2009-Dec-29 15:59 UTC
[rspec-users] Submitting a Custom Matcher: gem or other method?
On Tue, Dec 29, 2009 at 9:53 AM, Ed Howland <ed.howland at gmail.com> wrote:> On Tue, Dec 29, 2009 at 10:09 AM, David Chelimsky <dchelimsky at gmail.com> > wrote:> That said, I definitely think we need a home for information about > matchers. > > Hosting them, however, is something I''d rather leave to the professionals > :) > > I''ve imagined a website where folks can list info about matcher libraries > > and others can comment and possibly vote on them. If anybody wants to > > volunteer to drive this in the short run, that would be great, but I > won''t > > be able to do it myself for several months. > > Cheers, > > David > > Just a suggestion, several other projects have contributions listed on > their Git hub wiki. Can we create a page for them, linking to other > Github accounts. I don''t knoe about voting and such, but it might be a > start. The rspec.info page can just link to the Github wiki for a user > submitted contributions page and people can go from there. Thereby > offloading the responsibility. > > If I can help help in any way, let me know. >I started http://wiki.github.com/dchelimsky/rspec/matcher-libraries. Please feel free to modify/add. Ed> > -- > Ed Howland > http://greenprogrammer.wordpress.com > http://twitter.com/ed_howland >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20091229/62ae1937/attachment.html>
Ashley Moran
2009-Dec-30 22:31 UTC
[rspec-users] Submitting a Custom Matcher: gem or other method?
On 29 Dec 2009, at 15:59, David Chelimsky wrote:> I started http://wiki.github.com/dchelimsky/rspec/matcher-libraries. Please feel free to modify/add.I like! A wiki solves 90% of problems like this with 2% of the effort. I hadn''t realised the wiki had moved along - unlike Cucumber, I still see the static site as the primary reference. Wasn''t expecting you to drop everything and build a matcher hosting platform :) Cheers Ashley -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran
Matt Wynne
2009-Dec-31 17:38 UTC
[rspec-users] Submitting a Custom Matcher: gem or other method?
On 30 Dec 2009, at 22:31, Ashley Moran wrote:> Wasn''t expecting you to drop everything and build a matcher hosting > platform :)I think he should. It is Christmas, and it''s not like David ever does anything else for the community ;) cheers, Matt http://mattwynne.net +447974 430184