Gem 功能无法正确加载实际的 Gem 代码
我有一个带有 cukes 和扩展 RSpec 主题的规格的宝石。
所有规格都运行良好,但功能似乎无法正确加载当前的 gem 代码。不过似乎部分存在。
该宝石位于 https://github.com/ZenCocoon/rspec-subject-extensions
注意:对黄瓜不熟悉,我可能跳过了一些明显的东西。
I've got a gem with cukes and specs that extend RSpec subjects.
All specs runs fine but the features doesn't seem to properly load the current gem code. Seems partially there though.
The gem is at https://github.com/ZenCocoon/rspec-subject-extensions
Note: New to cucumber, I might have skipped something obvious.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为 rspec 是作为单独的进程启动的。您在 Cucumber 功能中定义的规范文件不需要这些扩展名,因此它们将不可用。它在您的 RSpec 测试中起作用的原因是您确实需要这些扩展。
要解决此问题,您可以在 Cucumber 功能的顶部添加一行以请求 rspec/subject/extensions.rb 文件:
这将解决该问题。
This is because
rspec
is being launched as a separate process. The spec file you're defining in your Cucumber feature does not require these extensions and so they won't be made available. The reason it's working in your RSpec tests is because you do require these extensions.To fix this, you can add one line to the top of your Cucumber feature to require the
rspec/subject/extensions.rb
file:This will fix the problem.