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

Can't test for html or body tags #48

Closed getaaron closed 7 years ago

getaaron commented 8 years ago

This test passes, but it should fail:

describe "index" do
  it "does something weird" do
    expect("<h1>just a header</h1>").to have_tag("html")
  end
end

The same behavior exists with have_tag("body").

I think it's because of this line, which passes the string straight into Nokogiri::HTML.

Two questions:

  1. Is there a workaround where I can test for html and body tags?
  2. If not, should have_tag raise an exception when it's passed these tags so developers know not to rely on them?
randoum commented 7 years ago

@getaaron if you are still on this, would you mind to check #59 and see if your issues are fixed ?

getaaron commented 7 years ago

@randoum I have a new job so I don't have access to that project any more. What do you think about adding my example test above to the specs in your PR? Just change to to not_to

randoum commented 7 years ago

@getaaron I'm closing this issue because you are not affected anymore. Thanks