2011-06-02 18 views
0

私はと、ユーザーの最初の作成「レイアウトを埋める」と題し、第5章を完了したら、私はRSpecの走ったと私は、次の取得:マイケル・ハートルガイド第5章RSpecの問題

1) PagesController GET 'home' should have the right title 
Failure/Error: response.should have_selector("title", :content => "Ruby on Rails Tutorial Sample App | Home") 
    expected following output to contain a <title>Ruby on Rails Tutorial Sample App | Home</title> 

2) PagesController GET 'contact' should have the right title 
Failure/Error: response.should have_selector("title", :content => "Ruby on Rails Tutorial Sample App | Contact") 
    expected following output to contain a <title>Ruby on Rails Tutorial Sample App | Contact</title> 

3) PagesController GET 'about' should have the right title 
Failure/Error: response.should have_selector("title", :content => "Ruby on Rails Tutorial Sample App | About") 
    expected following output to contain a <title>Ruby on Rails Tutorial Sample App | About</title> 

私は私は何をしているのか分かりません。また、ページが完全に罰金起動するだけでなく

ここをPagesControllerコード は 'spec_helper'

describe PagesController do 
    render_views 

    describe "GET 'home'" do 
    it "should be successful" do 
     get 'home' 
     response.should be_success 
    end 

    it "should have the right title" do 
     get 'home' 
     response.should have_selector("title", :content => "Ruby on Rails Tutorial Sample App | Home") 
    end 
    end 

    describe "GET 'contact'" do 
    it "should be successful" do 
     get 'contact' 
     response.should be_success 
    end 

    it "should have the right title" do 
     get 'contact' 
     response.should have_selector("title", :content => "Ruby on Rails Tutorial Sample App | Contact") 
    end 
    end 

    describe "GET 'about'" do 
    it "should be successful" do 
     get 'about' 
     response.should be_success 
    end 

    it "should have the right title" do 
     get 'about' 
     response.should have_selector("title", :content => "Ruby on Rails Tutorial Sample App | About") 
    end 
    end 
end 

はまた、ここに私のアプリ/ビュー/レイアウト/ application.html.erb

<title><%= @title %></title> 
がある必要されます

ここは私のlayout_links_specです

require 'spec_helper' 


it "should have a Home page at '/'" do 
    get '/' 
    response.should have_selector('title', :content => "Home") 
end 

it "should have a Contact page at '/contact'" do 
    get '/contact' 
    response.should have_selector('title', :content => "Contact") 
end 

it "should have have an About page at '/about" do 
    get '/about' 
    response.should have_selector('title', :content => "About") 
end 

it "should have a Help pageat '/help'" do 
    get '/help' 
    response.should have_selector('title', :content => "Help") 
end 

it "should have a signup page at '/signup'" do 
    get '/signup' 
    response.should have_selector('title', :content => "Sign up") 
end 

it "should have the right links on the layout" do 
    visit root_path 
    response.should have_selector('title', :content => "Home") 
end 
end 
+0

この問題を引き起こしている第5章の関連コードまたは特定のセクションを表示してください。 –

+0

マイコードが追加されました – matt

答えて

3

require 'spec_helper' 

describe UsersController do 
    render_views 

    describe "GET 'new'" do 
    it "should be successful" do 
     get :new 
     response.should be_success 
    end 

    it "should have the right title" do 
     get :new 
     response.should have_selector("title", :content => "Sign up") 
    end 
    end 
end 
+0

render_viewsが含まれていることを確認してください。これだよ!。 – mdskinner

1

render_views ncludedこれは、正確なエラーが何であったかを見つけ出すが、彼らはマイクのチュートリアルにレイアウトされているとして、あなたが指示に従っていることを確認するために私にいくつかの時間がかかりました。

マイクは非常に効率的かつ徹底的ですが、ステップをスキップするとエラーが発生します。私は同じ問題を見て、まずリスト5.20から最新のstatic_pages_spec.rbを使用していることを確認する必要があります。5.23の最新ルートファイルがあり、public\index.htmlファイルが削除されていることを確認してください。

これらの手順を完了するとエラーは消えてしまいます。

関連する問題