title: How to test for non existing html tag in rspec/capybara
body: <p>For a controller delivering some html snippet (used as ajax call), I have a view spec looking like that:</p>
  
  <pre><code>it "should not contain html element" do
      render
      rendered.should have_selector('div')
      rendered.should_not have_selector('html')
  end
  </code></pre>
  
  <p>Since our ajax content loader doesn't allow a full html page to be rendered, I want to check that the result does not contain an html tag.</p>
  
  <p>For now the result in <code>rendered</code> is a simple div tag:</p>
  
  <pre><code>puts rendered
  </code></pre>
  
  <p>leads to</p>
  
  <pre><code>"&lt;div&gt;Some text&lt;/div&gt;"
  </code></pre>
  
  <p>However, the test fails:</p>
  
  <pre><code>Failure/Error: rendered.should_not have_selector('html')
    Capybara::ExpectationNotMet:
    expected not to find css "html", found 1 match: "Some text"
  </code></pre>
  
  <p>I also tried it with</p>
  
  <pre><code>rendered.should_not have_xpath('//html')
  rendered.should_not have_css('html')
  rendered.should have_no_xpath('//html')
  rendered.should have_no_css('html')
  </code></pre>
  
  <p>but the result stays the same.</p>
  
  <p>Why is a check for <code>html</code> matching the text <strong>inside</strong> the <code>div</code>? Even a test for <code>body</code> leads to the same result.</p>