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

Match attribute with any value #40

Closed vfonic closed 7 years ago

vfonic commented 8 years ago

Hi,

Thanks for great gem!

I'm writing a test for a helper method for <img srcset="" />. I don't want srcset attribute to be rendered when it's not provided in options (when it's empty).

I'm trying to match if the attribute renders at all with any value. Is this possible?

Another use case that comes to my mind would be: <input type="checkbox" checked /> or any similar form tag.

kucaahbe commented 8 years ago

correct @vfonic this is not implemented for now, and honestly not sure if I have time for this in some near future, so would be awesome if we could have pull request for that ;)

vfonic commented 8 years ago

Thanks for reply @kucaahbe I'm also short on time lately, but if I find any, I'll send a PR.

kucaahbe commented 8 years ago

Thanks @vfonic !

skalee commented 8 years ago

@vfonic Why not with_tag("img[srcset]")? See: https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors

getaaron commented 8 years ago

@skalee FYI, I just updated the README to show this approach

vfonic commented 8 years ago

Great, thanks!