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