如何在RSPEC测试工作中制作自定义模块?
我正在尝试将自定义模块包括在RSPEC测试中。但是,我一直遇到错误,告诉我它找不到我的模块,它说了NameRor:非专业化的常量Authhelper。
我一直在尝试遵循此 https://stackoverflow.com/a/68669816/55568244
我不知道在哪里要放置该模块,以便我创建了一个名为spec/support/的文件夹和一个名为auth_helper.rb的文件,然后放入module authhelper ...等...结束
,因为
我尝试了简单地包括它在测试
规格/请求/topics_specs.rb
require 'rails_helper'
include AuthHelper
中,我希望能够自动在支持文件夹中找到该模块,但没有。应该吗? RSPEC是否在特定的地方看?
我还尝试设置rails_helper.rb文件以包含它,
RSpec.configure do |config|
config.include(AuthHelper, :type => :request)
end
但这仍然不起作用。
我想念什么?这个应该如何工作?
I am trying to include a custom module into an RSpec test. However, I keep getting errors telling me it can't find my module, it says NameError: uninitialized constant AuthHelper.
I have been trying to follow this https://stackoverflow.com/a/68669816/5568244
I didn't know where to put the the module so I created a folder called specs/support/ and a file called auth_helper.rb in it and put module AuthHelper ...etc... end
in that
I have tried simply including it in the test
spec/requests/topics_specs.rb
require 'rails_helper'
include AuthHelper
which i expected to be able to just automatically find the module in the support folder but it didn't. Should it? Does RSpec look in specific places?
I also tried to set up the rails_helper.rb file to include it
RSpec.configure do |config|
config.include(AuthHelper, :type => :request)
end
This still didn't work.
What am i missing? How should this work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论