title: How can I test the page title with Capybara 2.0?
body: <p>Trying to test that page contains <code>&lt;title&gt;My Title&lt;/title&gt;</code> with:</p>
  
  <pre><code># spec/features/reports_spec.rb
  require 'spec_helper'
  
  feature "Archive Management" do
    subject { page }
  
    describe "Index Page" do
      before(:all) { 10.times { FactoryGirl.create(:randomreport) } }
      after(:all) { Report.delete_all }
  
      describe "when no search terms present" do
        before { visit reports_path }
  
        it { should have_selector('title', text: 'My Title') } # &lt;= Fails w/Capybara 2.0
        it { should have_selector('title') }                   # &lt;= passes
        it { should have_text('My Title') }                    # &lt;= passes
        it { should have_selector('h2', text: "Welcome") }     # &lt;= passes
      end
    end
  end
  </code></pre>
  
  <p>Error message: </p>
  
  <pre><code> Failure/Error: it { should have_selector('title', text: base_title) }
   Capybara::ExpectationNotMet:
     expected to find css "title" with text "My Title" but there were no matches. Also found "", which matched the selector but not all filters.
  </code></pre>
  
  <p>I know I'm overlooking the painfully obvious but can't figure out what it is? Are <code>&lt;title&gt;</code> tags no longer considered 'selectors'?!? Or...?!? </p>
  
  <p><strong>Edit (debugger info)</strong>: </p>
  
  <p>If I drop down into the debugger as cleverly suggested by @shioyama it is clear that the page.body contains <code>&lt;title&gt;My Title&lt;/title&gt;</code>. The same page.body that contains <code>&lt;h2&gt;Welcome to My Title Project&lt;/h2&gt;</code> and passes! </p>
  
  <p>It appears to find the <code>&lt;title&gt;</code>...<code>&lt;/title&gt;</code> tag but not <code>My Title</code> within it. But it does find <code>My Title</code> later in the page within <code>&lt;a href=\"/\" class=\"brand\"&gt;My Title&lt;/a&gt;</code> and/or in <code>&lt;h2&gt;Welcome to The My Title Project&lt;/h2&gt;</code>:</p>
  
  <pre><code>(rdb:1) p page
  #&lt;Capybara::Session&gt;
  (rdb:1) p page.body
  "&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n&lt;title&gt;My Title&lt;/title&gt;\n
  &lt;meta content='research, report, technology' name='keywords'&gt;\n&lt;meta 
  content='Some Project' name='description'&gt;\n&lt;link href=\"/assets/application.css\"
  ...
  &lt;/head&gt;\n&lt;body&gt;\n&lt;header class='navbar navbar-fixed-top 
  navbar-inverse'&gt;\n&lt;div class='navbar-inner'&gt;\n&lt;div class='container'&gt;\n
  &lt;a href=\"/\" class=\"brand\"&gt;My Title&lt;/a&gt;\n&lt;div class='pull-right'&gt;\n
  &lt;ul class='nav'&gt;\n&lt;li&gt;&lt;a href=\"/about\"&gt;About&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"/help\"&gt;Help&lt;/a&gt;
  &lt;/li&gt;\n&lt;/ul&gt;\n&lt;form accept-charset=\"UTF-8\" action=\"/reports\" 
  class=\"navbar-search\" method=\"get\"&gt;&lt;div style=\"margin:0;padding:0;display:inline\"&gt;
  &lt;input name=\"utf8\" type=\"hidden\" value=\"&amp;#x2713;\" /&gt;&lt;/div&gt;\n
  &lt;input class=\"search-query\" id=\"query\" name=\"query\" 
  placeholder=\"Search\" type=\"text\" /&gt;\n&lt;/form&gt;\n\n&lt;/div&gt;\n&lt;/div&gt;\n&lt;/div&gt;\n&lt;/header&gt;\n\n
  &lt;div class='container'&gt;\n&lt;div class='hero-unit center'&gt;\n&lt;h1&gt;My Title&lt;/h1&gt;\n
  &lt;h2&gt;Welcome to The My Title Project&lt;/h2&gt;\n&lt;p&gt;Lorem ipsum dolor sit amet, consectetur 
  adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 
  ...
  </code></pre>
  
  <p>What else could I try in the debugger to figure out why have_selector?('title', text: ...) is failing?</p>
  
  <p><strong>So, what is the proper way to test for a title in Capybara 2.0?</strong></p>