RSpec控制器测试因Rails API失败-未定义方法' helpers' [英] RSpec controller test failing with Rails API - Undefined Method 'helpers'

查看:77
本文介绍了RSpec控制器测试因Rails API失败-未定义方法' helpers'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试遵循 Rails API指南,以便更好地了解如何集成Rails将API插入我自己的应用程序中,但是我的RSpec测试在路由预期上失败了,我不确定为什么.

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.

我的错误消息是

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 ^^

推荐答案

我也在使用Rails 5并升级到"rspec-rails",〜> 3.5"似乎可以解决问题!谢谢

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

这篇关于RSpec控制器测试因Rails API失败-未定义方法&amp;#39; helpers&amp;#39;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆