Ruby on rails 3 迈克尔·哈特尔指南第5章rspec发行
一旦我完成了第5章,题为“填充布局”,以及用户的初始创建,我运行了rspec,我得到了以下信息:Ruby on rails 3 迈克尔·哈特尔指南第5章rspec发行,ruby-on-rails-3,Ruby On Rails 3,一旦我完成了第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
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>
这里还有我的app/views/layouts/application.html.erb
<title><%= @title %></title>
确保已包含渲染视图
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
确保已包含渲染视图
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
我花了一些时间才弄清楚确切的错误是什么,但请确保您按照Mike教程中的说明进行操作 迈克很有效率,也很彻底,但如果你跳过一步,就会出错。我看到了同样的问题,首先您需要确保使用的是清单5.20中最新的
static\u pages\u spec.rb
,清单5.23中最新的路由文件,并确保删除public\index.html
文件
完成这些步骤后,您的错误应该会消失。我花了一些时间才弄清楚确切的错误是什么,但请确保您按照Mike教程中的说明进行操作 迈克很有效率,也很彻底,但如果你跳过一步,就会出错。我看到了同样的问题,首先您需要确保使用的是清单5.20中最新的
static\u pages\u spec.rb
,清单5.23中最新的路由文件,并确保删除public\index.html
文件
完成这些步骤后,您的错误应该会消失。请向我们展示导致此问题的第5章中的相关代码或特定章节。请向我们展示导致此问题的第5章中的相关代码或特定章节。
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