rspec 中的别名“it" [英] alias 'it' in rspec
问题描述
我正在尝试在 ROR 应用程序的 rspec 中编写一些测试(不是为了代码覆盖率,但在这里无关紧要),并且至少需要别名描述和它.我可以用别名来描述就好了,因为它在顶层.但是,我不能让其他任何东西工作.喜欢这个人:
I'm trying to write some tests (not for code coverage, but irrelevant here) in rspec for a ROR app and need to alias describe and it, at the least. I can alias describe just fine because it's at the top level. But, I can't get anything else to work. like this guy:
module RSpec
module Core
class ExampleGroupMethods
alias :they :it
end
end
end
我将其包含在规范文件中,但我没有正确获取模块路径.我查看了 rspec 代码库,但碰壁了,所以我想我不太清楚自己在做什么.任何提示或资源将不胜感激.
I included that in the spec file but I am not getting the module path right. I looked over the rspec codebase but am hitting a wall so I don't think I quite know what I'm doing. Any tips or resources would be greatly appreciated.
推荐答案
您想使用 <代码>alias_example_to:
RSpec.configure do |c|
c.alias_example_to :they
end
这是 RSpec 公共 API 的一部分.
This is part of the public API of RSpec.
这篇关于rspec 中的别名“it"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!