问题
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