Topic: Help with my RSpec setup (i think) please

I am following this tutorial http://ruby.railstutorial.org/chapters/ … c_pagesFor some reason my tests fail after I start using application.html.erb

I am following this tutorial http://ruby.railstutorial.org/chapters/ … atic_pages
For some reason my tests fail after I start using application.html.erb

my test
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 => 'Sample App')
    end

    it "should have the title 'Home'" do
      visit '/static_pages/home'
      page.should have_selector('title',
                                :text => "Ruby on Rails Tutorial Sample App | Home")
    end
  end
end


This passes if my home.html.erb file is
<!DOCTYPE html>
<html>
  <head>
    <title>Ruby on Rails Tutorial Sample App | Home</title>
  </head>
  <body>
    <h1>Sample App</h1>
    <p>
      This is the home page for the
      <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
      sample application.
    </p>
  </body>
</html>

however it fails the title test and passes h1 test the  when try to use application.html.erb, the files are
home.html.erb
<% provide(:title, 'Home') %>
<h1>Sample App</h1>
<p>
  This is the home page for the
  <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
  sample application.
</p>
and application.html.erb
<!DOCTYPE html>
<html>
<head>
  <title>Ruby on Rails Tutorial Sample App | <%= yield(:title) %></title>
  <%= stylesheet_link_tag    "application", :media => "all" %>
  <%= javascript_include_tag "application" %>
  <%= csrf_meta_tags %>
</head>
<body>

<%= yield %>

</body>
</html>

even though the HTML i get when I browse to http://localhost:3000/static_pages/home contains the correct title

<!DOCTYPE html>
<html>
<head>
  <title>Ruby on Rails Tutorial Sample App | Home</title>
  <link href="/assets/application.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/static_pages.css?body=1" media="all" rel="stylesheet" type="text/css" />
  <script src="/assets/jquery.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
<script src="/assets/application.js?body=1" type="text/javascript"></script>
  <meta content="authenticity_token" name="csrf-param" />
<meta content="TIelChafkyp0daGayyd2+eOgMdAeQObxwbcW7JjP3Oc=" name="csrf-token" />
</head>
<body>

<h1>Sample App</h1>
<p>
  This is the home page for the
  <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
  sample application.
</p>

</body>
</html>


so this must be something wrong with my testing somehow? any ideas please as I'm going round in circles and haven't been able to find any help searching the net.

Thanks Roy

Last edited by ROyTheB0y (2013-05-30 13:40:53)