title: What is wrong with this Rspec test
body: <p>I am new to TDD test driven development and I am trying to do my first few tests and i have this test failing even when i know the title is clearly on the page</p>
  
  <pre><code>  response.should have_selector("title", :content =&gt; "Ruby on Rails | Home")
  </code></pre>
  
  <p>any ideas what i am doing wrong and/or if there is a list of rspec helpers somewhere online. This is a rails 3.2.1 application btw</p>
  
  <p>Update the test is failing with this error</p>
  
  <pre><code>Failures:
  
    1) PagesController GET 'home' should have the right title
       Failure/Error: response.should have_selector("title", :content =&gt; "Ruby on Rails | Home")
         expected following output to contain a &lt;title&gt;Ruby on Rails | Home&lt;/title&gt; tag:
         &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"&gt;
       # ./spec/controllers/pages_controller_spec.rb:13:in `block (3 levels) in &lt;top (required)&gt;'
  
  Finished in 0.17154 seconds
  4 examples, 1 failure
  
  Failed examples:
  
  rspec ./spec/controllers/pages_controller_spec.rb:11 # PagesController GET 'home' should have the right title
  </code></pre>
  
  <p>my application.html.haml is </p>
  
  <pre><code>!!! Strict
  %html{ :xmlns =&gt; "http://www.w3.org/1999/xhtml", 'xml:lang'=&gt;"en", :lang=&gt;"en" }
  %head
    %title= "Ruby on Rails | Home"
    = stylesheet_link_tag    "application", :media =&gt; "all"
    = javascript_include_tag "application"
    = csrf_meta_tags
  %body
    = yield
  
  
  
    1) PagesController GET 'home' should have the right title
       Failure/Error: page.should have_selector("title", :content =&gt; "Ruby on Rails | Home")
       NameError:
         undefined local variable or method `page' for #&lt;RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x000001011b22e8&gt;
       # ./spec/controllers/pages_controller_spec.rb:13:in `block (3 levels) in &lt;top (required)&gt;'
  
  Finished in 0.16401 seconds
  4 examples, 1 failure
  
  Failed examples:
  
  rspec ./spec/controllers/pages_controller_spec.rb:11 # PagesController GET 'home' should have the right title
  </code></pre>
  
  <p>UPDATE</p>
  
  <p>here is my spec controller with all the tests passing except for the one in question </p>
  
  <pre><code>require 'spec_helper'
  
  describe PagesController do
  
  
  
    describe "GET 'home'" do
  
      subject { page }
  
      it "returns http success" do
        get 'home'
        response.should be_success
      end
  
      it "should have the right title" do
        get 'home'
        page.should have_selector("title", :content =&gt; "Ruby on Rails | Home")
      end
  
      it "should render template" do
        get 'home'
        response.should render_template('pages/home')
      end
  
    end
  
    describe "GET 'contact'" do
      it "returns http success" do
        get 'contact'
        response.should be_success
      end
    end
  
    describe "GET 'about'" do
      it "returns http success" do
        get 'about'
        response.should be_success
      end
    end
  
  end
  </code></pre>
  
  <p>Yet another update...here is my source when i view source on the page</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'&gt;
    &lt;head&gt;
      &lt;title&gt;Ruby on Rails | Home&lt;/title&gt;
      &lt;link href="/assets/application.css?body=1" media="all" rel="stylesheet" type="text/css" /&gt;
      &lt;link href="/assets/pages.css?body=1" media="all" rel="stylesheet" type="text/css" /&gt;
      &lt;script src="/assets/jquery.js?body=1" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="/assets/jquery_ujs.js?body=1" type="text/javascript"&gt;&lt;/script&gt;
  
      &lt;script src="/assets/pages.js?body=1" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="/assets/application.js?body=1" type="text/javascript"&gt;&lt;/script&gt;
      &lt;meta content="authenticity_token" name="csrf-param" /&gt;
      &lt;meta content="fi3Er/VJrzhpb5FPAcT0DYT9RFNu1oW3p4og5dg+jFc=" name="csrf-token" /&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;h1&gt;Pages#home&lt;/h1&gt;
  
      &lt;p&gt;
        Find me in app/views/pages/home.html
      &lt;/p&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>yes another update</p>
  
  <pre><code>gem 'rails', '3.2.1'
  gem 'mysql2'
  
  
  # Gems used only for assets and not required
  # in production environments by default.
  group :assets do
    gem 'sass-rails',   '~&gt; 3.2.3'
    gem 'coffee-rails', '~&gt; 3.2.1'
  
    # See https://github.com/sstephenson/execjs#readme for more supported runtimes
    # gem 'therubyracer'
  
    gem 'uglifier', '&gt;= 1.0.3'
  end
  
  group :development do
    gem 'rspec-rails', '2.8.1'
  end
  
  group :test do
    gem 'rspec', '2.8.0'
      gem 'webrat', '0.7.3'
  end
  
  gem 'jquery-rails'
  gem "haml", "~&gt; 3.1.4"
  </code></pre>