我正在关注Rails Tutorial website中的示例,并且遇到了使集成测试正常工作的问题。特别是本教程中section 8.4.2中列表8.20的示例。路由在RSpec集成测试中不可用
在低于访问signup_path行的代码,我得到以下错误: “未定义的局部变量或方法`signup_path'”
require 'spec_helper'
describe "Users" do
describe "signup" do
describe "failure" do
it "should not make a new user" do
visit signup_path
fill_in "Name", :with => ""
fill_in "Email", :with => ""
fill_in "Password", :with => ""
fill_in "Confirmation", :with => ""
click_button
response.should render_template("users/new")
response.should have_selector("div#error_explanation")
end
end
end
end
Here's the full test file on github
但是,如果我运行所有立即进行测试,然后我不会收到错误。错误只发生在我运行单个测试时。
我的项目可以在GitHub上查看here
如何解决这个问题?
消除行'response.should render_template('users/new')'摆脱我得到的错误,'@request必须是ActionDispatch :: Request',但响应页是空的。这个例子不正确或过时,因为它在教程中? – 2011-02-07 13:34:00