预期响应为但
我的rspec测试存在问题,并且查看了以前的问题,我无法解决它。 测试失败并出现上述错误,但代码在实践中有效,有没有人知道如何解决这个问题?
Rspec的:
describe "authentication of edit/update pages" do before(:each) do @user = Factory(:user) end describe "for non-signed in users" do it "should deny access to 'edit'" do get :edit, :id => @user response.should redirect_to(signin_path) end it "should deny access to 'update'" do put :update, :id => @user, :user => {} response.should redirect_to(signin_path) end end end
会议助手:
def deny_access redirect_to signin_path, :notice => "Please sign in to access this page." end
用户控制器
class UsersController [:edit, :update] private def authenticate deny_access unless signed_in? end end
我猜你应该稍微修改你的代码:
def deny_access redirect_to signin_path, :notice => "Please sign in to access this page." and return end