kucaahbe/rspec-html-matchers

Can't test for html or body tags

Closed this issue · 3 comments

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?

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

@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

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