kucaahbe / rspec-html-matchers

Old school have_tag, with_tag(and more) matchers for rspec 3 (Nokogiri powered)
http://rubygems.org/gems/rspec-html-matchers
MIT License
199 stars 90 forks source link

Allow matching on XML document #66

Closed derfred closed 6 years ago

derfred commented 7 years ago

Extends the have_tag matcher with the xml parameter, which switches to using the nokogiri XML parser.

datenimperator commented 6 years ago

I just spent 2 hours trying to find why my XML doc didn't test successfully. Would love to see this merged.

kucaahbe commented 6 years ago

extending library functionality with XML matching sounds not really good to me (btw. please note the name, it's "html" there, and that's not by accident). And here the reason: XML documents potentially have more complicated structure, and as result there could be more requests about adding more matching functionality, making it hard to maintain proper documentation for end-user and code for maintainers. Generally speaking, this tool already provides a lot options to test things, making it super easy to actually abuse this, e.g. making tests itself hard to understand and maintain.

So I would not experiment with XML extending, it's open source world and anybody can create a fork with own functionality and use it, see how it goes and decide it is it's actually needed functionality, or completely another tool is more appropriate.

Please let me know what do you think

datenimperator commented 6 years ago

You're right about the name, as well as the possible downsides of adding half-backed XML support. I went with a simple custom matcher suitable for my case, found inspiration on https://gist.github.com/pimpin/65a39d6e932f44b32fd3

Thanks nonetheless.