RSpec controller test failing with Rails API - Undefined Method 'helpers'

这一生的挚爱 提交于 2019-12-22 12:43:38

问题


I'm trying to follow this Rails API Guide to better understand how to integrate the Rails API into my own application, however my RSpec test is failing on the routing expectation and I'm not sure why.

My error message is

1) Api::V1::UsersController POST #create when is not created renders an errors json
     Failure/Error: expect(user_response).to have_key(:errors)
     NoMethodError:
     undefined method "helpers" for #   <ActionDispatch::Routing::RouteSet::NamedRouteCollection:0x007f7f8a1c0938>
       Did you mean?  helper_names
     # ./spec/controllers/api/v1/users_controller_spec.rb:47:in <block (4 levels) in top (required)>'

I think linking this Gist might be more convenient for the sake of posting code. I apologize if posting plaintext directly on my post is preferred. I'm new to posting ^^


回答1:


I am also using Rails 5 and upgrading to "rspec-rails", "~> 3.5" seems to have done the trick! thanks



来源:https://stackoverflow.com/questions/39030916/rspec-controller-test-failing-with-rails-api-undefined-method-helpers

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