我一直在写一些rspec测试,现在我想验证用户创建后的重定向。许多其他测试工作,包括创建用户。Rails Rspec路由错误当路由明显存在
然而,最后下面的测试失败:
describe "success" do
before(:each) do
@attr = { :username => "woweee123",
:email => "[email protected]",
:password => "password123",
:password_confirmation => "password123"}
end
it "should create the user" do
lambda do
post :create, :user => @attr
end.should change(User, :count)
end
it "should redirect to a user show page after creation" do
lambda do
post :create, :user => @attr
end.should redirect_to(user_path(assigns(:user)))
end
end
失败的测试是:没有路由匹配{:动作=> “秀”,:控制器=> “用户”
但,当我手动创建一个用户(在localhost上)时,重定向显然起作用。为什么这是失败的?