0
我一直在有这个问题了,而有一个主页,我似乎无法绕到我的大脑,我已经重新一切从头开始了无数次迈克尔·哈特尔指南第5章LayoutLinks应在“/”问题
无论如何,我在这本书的一部分,我们希望主页链接从http://localhost:3000/pages/home(这工作完美顺便)到http://localhost:3000 (基本上意思是我希望主页显示在根页面上)
目前我的错误是 LayoutLinks应该有一个主页'/' 失败/错误:response.should have_选择器('标题',:内容=>“首页”) 它下面是一堆文字说这个页面应该看起来像。
现在我做了两件事情,我第一次创建layout_links_spec.rb页面,添加了帮助页面的pages_controller.rb,并添加路由配置低于/ routes.rb中是所有3
代码layout_links_spec.rb
require 'spec_helper'
describe "LayoutLinks" do
# describe "GET /layout_links" do
# it "works! (now write some real specs)" do
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers
# get layout_links_index_path
# response.status.should be(200)
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 '/about'
response.should have_selector('title', :content => "About")
end
it "should have a Help page '/help'" do
get '/help'
response.should have_selector('title', :content => "Help")
end
end
Pages_controller.rb
def home
@title = "Home"
end
def contact
@title = "Contact"
end
def about
@title = "About"
end
def help
@title = "Help"
end
end
配置/ routes.rb中
SampleApp::Application.routes.draw do
match '/contact', :to => 'pages#contact'
match '/about', :to => 'pages#about'
match '/help', :to => 'pages#help'
root :to => 'pages#home'
end
有什么我做错了吗?
它在那里我只是忘了添加它 – matt 2011-06-09 02:34:36
你看到根页/如果你手动检查它? – 2011-06-09 02:42:14
你是什么意思手动检查它?你是说如果我喜欢/家? – matt 2011-06-09 02:54:38