升级后运行规格后,我将应用程序从rails 4升级到rails 5并将rspec-rails从3.0升级到3.6后出现错误:
No route matches {:action=>"/login", :controller=>"posts", :session=>{:email=>"email@example.com", :password=>"password"}}
我的路线定义如下:
post 'login' => 'sessions#create'
我试图从我的帮手那样访问它:
def log_in_as(user, options = {})
post login_path , params:{session: { email: user.email,
password: "password"}}
end
在我的控制器规范中:
RSpec.describe PostsController, type: :controller, posts: true
do
before(:each) { setup }
def setup
@user = FactoryGirl.create(:user, email: 'email@example.com')
log_in_as @user
end
#tests Code...
end
修改
耙路线| grep登录输出:
sessions#new login GET /login(.:format)
sessions#create POST /login(.:format)