一旦我完成了第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
请向我们展示第5章中导致此问题的相关代码或特定部分。 – 2011-06-02 23:02:35
我的代码被添加 – matt 2011-06-02 23:37:40