我正在关注 Hartl 的 Ruby on Rails 教程,但无法弄清楚为什么以下代码不断给我这个错误:
Failure/Error: expect(response).to render_template("membres/show")
NoMethodError:
undefined method `body' for nil:NilClass
编码:
require 'rails_helper'
RSpec.describe "Membres", :type => :request do
include Capybara::DSL
describe "une inscription" do
describe "ratée" do
it "ne devrait pas créer un nouvel utilisateur" do
visit signup_path
fill_in "Nom", :with => ""
fill_in "Email", :with => ""
fill_in "Password", :with => ""
fill_in "Confirmation", :with => ""
click_button "Inscription"
expect(response).to render_template("membres/show")
expect(response).to have_tag("div#error_explanation")
end
end
end
end
我尝试在错误的行上使用“页面”而不是“响应”,我还尝试了其他链接而不是“成员/显示”,但没有任何效果。
有人对此有任何想法吗?
编辑
我应该使用它绝对是“页面”而不是“响应”,但这仍然不能清除错误消息。