title: RSpec Failure: "Static Pages X should have title X" -- Tried with have_xpath & have_selector
body: <p>I've been scouring the web &amp; Stack Overflow to tr and figure out how to get these tests working. I'm brand new to Ruby &amp; to Rails, I'm simply following along Hartl's tutorial - copy pasting most of the code to see how it all falls together in the end. </p>
  
  <p>Now, I'm getting stuck in section 3.3 "Slightly Dynamic Pages". </p>
  
  <p>This is the error I'm recieving: </p>
  
  <pre><code>C:\Sites\sample_app&gt;bundle exec rspec --no-color spec/requests/static_pages_spec.rb
  F.F.F.
  
  Failures:
  
    1) Static pages About page should have the title 'About Us'
   Failure/Error: page.should have_selector('title',
     expected css "title" with text "Ruby on Rails Tutorial Sample App | About Us" to return something
   # ./spec/requests/static_pages_spec.rb:44:in `block (3 levels) in &lt;top (required)&gt;'
  
    2) Static pages Help page should have the title 'Help'
   Failure/Error: page.should have_selector('title',
     expected css "title" with text "Ruby on Rails Tutorial Sample App | Help" to return something
   # ./spec/requests/static_pages_spec.rb:29:in `block (3 levels) in &lt;top (required)&gt;'
  
    3) Static pages Home page should have the title 'Home'
   Failure/Error: page.should have_selector('title',
     expected css "title" with text "Ruby on Rails Tutorial Sample App | Home" to return something
   # ./spec/requests/static_pages_spec.rb:14:in `block (3 levels) in &lt;top (required)&gt;'
  
  Finished in 3.09 seconds
  6 examples, 3 failures
  
  Failed examples:
  
  rspec ./spec/requests/static_pages_spec.rb:42 # Static pages About page should have the title 'About Us'
  rspec ./spec/requests/static_pages_spec.rb:27 # Static pages Help page should have the title 'Help'
  rspec ./spec/requests/static_pages_spec.rb:12 # Static pages Home page should have the title 'Home'
  
  Randomized with seed 25648
  </code></pre>
  
  <p>The error is occuring as soon as I swtich from this HTML Structure (in my About/Home/Help.html.erb files): </p>
  
  <pre><code>&lt;% provide(:title, 'Home') %&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Ruby on Rails Tutorial Sample App | &lt;%= yield(:title) %&gt;&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
    &lt;h1&gt;Sample App&lt;/h1&gt;
      &lt;p&gt;
        This is the home page for the
        &lt;a href="http://railstutorial.org/"&gt;Ruby on Rails Tutorial&lt;/a&gt;
        sample application.
      &lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>To this:</strong> </p>
  
  <pre><code>&lt;% provide(:title, 'Home') %&gt;
  &lt;h1&gt;Sample App&lt;/h1&gt;
    &lt;p&gt;
       This is the home page for the
       &lt;a href="http://railstutorial.org/"&gt;Ruby on Rails Tutorial&lt;/a&gt;
       sample application.
    &lt;/p&gt;
  </code></pre>
  
  <p>Other related files:</p>
  
  <p><strong>Application.html.erb:</strong> </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Ruby on Rails Tutorial Sample App | &lt;%= yield(:title) %&gt;&lt;/title&gt;
      &lt;%= stylesheet_link_tag    "application", :media =&gt; "all" %&gt;
      &lt;%= javascript_include_tag "application" %&gt;
      &lt;%= csrf_meta_tags %&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;%= yield %&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>static_pages_spec.rb</strong></p>
  
  <pre><code>require 'spec_helper'
  
  describe "Static pages" do
  
  
  describe "Home page" do
    it "should have the h1 'Sample App'" do
      visit '/static_pages/home'
      page.should have_selector('h1', :text =&gt; 'Sample App')
    end
  
    it "should have the title 'Home'" do
      visit '/static_pages/home'
      page.should have_selector('title',
                      :text =&gt; "Ruby on Rails Tutorial Sample App | Home")
  
       // The line below is something I tried replacing the page.should have_selector with
      // page.should have_xpath("//title", :text =&gt; "Home")
    end
  end
  
  .... (other describe pages, same structure)
  
  end
  </code></pre>
  
  <p>I might've just gone blind over the course of copying/pasting/reading from Hartl's tutorial, but I am pretty damn sure it looks the same way as he described it. </p>
  
  <p>I've done my best at looking for a solution to this, but alas I haven't been able to figure it out, so here goes! </p>
  
  <p>Cheers! </p>
  
  <p>Edit: Answer to Fiona #1</p>
  
  <p>On this url : "http://localhost:3000/static_pages/home"</p>
  
  <p>The document title is nothing. </p>
  
  <p>The source of the document looks like this: </p>
  
  <pre><code>&lt;h1&gt;Sample App&lt;/h1&gt;
  &lt;p&gt;
    This is the home page for the
    &lt;a href="http://railstutorial.org/"&gt;Ruby on Rails Tutorial&lt;/a&gt;
    sample application.
  &lt;/p&gt;
  </code></pre>
  
  <p>There is no doctype, head, body or title declaration in the source. </p>