加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – RSpec:undefined方法`infer_spec_type_from_f

发布时间:2020-12-17 03:17:31 所属栏目:百科 来源:网络整理
导读:我正在为我的Rails控制器编写一些测试,我正在使用RSpec 3.0.2 收到此错误后,当我尝试模拟对路由的POST调用时: NoMethodError: undefined method `post' for # RSpec::ExampleGroups::WebApplicationsController::ProcessPayment:0x00000106214ce0 然后我读
我正在为我的Rails控制器编写一些测试,我正在使用RSpec 3.0.2

收到此错误后,当我尝试模拟对路由的POST调用时:

NoMethodError:
   undefined method `post' for #   <RSpec::ExampleGroups::WebApplicationsController::ProcessPayment:0x00000106214ce0>

然后我读了this SO thread并将以下行添加到我的spec_helper.rb中

RSpec.configuration.infer_spec_type_from_file_location!

当我运行rspec规范时,这给了我以下错误:

code/fsa/spec/spec_helper.rb:4:in `<top (required)>': undefined method `infer_spec_type_from_file_location!' for #<RSpec::Core::Configuration:0x0000010420e040> (NoMethodError)

我不确定发生了什么事.

解决方法

这是因为我使用gem’rspec’而不是gem rspec-rails

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读