Rspec undefined method 'helpers' for ActionDispatch Routing

有些话、适合烂在心里 提交于 2019-12-14 03:54:10

问题


I'm upgrading an old rails 3 app to rails 5 and also upgrading Rspec in the process. When running test, I get an error:

 NoMethodError Exception: undefined method `helpers' for #<ActionDispatch::Routing::RouteSet::NamedRouteCollection:0x007ffaf09d9200>

whenever I call be_success on a response. See example:

 it "renders 'OK' text when request is html" do
      get :ping
      expect(response).to be_success
      response.body.should == 'OK'
    end

I get the error when I run this test. After inserting a breakpoint, I see the error is thrown whenever be_success is called...

(byebug) be_success
*** NoMethodError Exception: undefined method `helpers' for #<ActionDispatch::Routing::RouteSet::NamedRouteCollection:0x007ffaf09d9200>
Did you mean?  helper_names

I have included config.include Rails.application.routes.url_helpers in my spec_helper file (had a similar issue with using rails routes paths), but it hasn't helped for this error.

来源:https://stackoverflow.com/questions/38647346/rspec-undefined-method-helpers-for-actiondispatch-routing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!