describe "Req #5 - login" do
it 'loads the login page' do
get '/login'
expect(last_response.status).to eq(200)
end
it 'loads the user index after login' do
user = User.create(:username => "Raptor", :password => "Raptor")
params = {
:username => "Raptor",
:password => "Raptor"
}
post '/login', params
follow_redirect!
expect(last_response.body).to include("Home Page for: Raptor")
end
end
2条答案
按热度按时间1hdlvixo1#
为什么不让rspec登录到您的测试系统,而不是stubbing current_user呢?您可以执行如下操作:
lymgl2op2#
您可以像这样存根控制器的current_user方法: