gpt4 book ai didi

ruby-on-rails - rspec 中的别名 'it'

转载 作者:行者123 更新时间:2023-12-04 02:59:18 25 4
gpt4 key购买 nike

我正在尝试在 rspec 中为 ROR 应用程序编写一些测试(不是用于代码覆盖,但与此处无关),并且至少需要别名 describe 和它。我可以别名描述就好了,因为它在顶层。但是,我不能让其他任何工作。像这个人:

module RSpec
module Core
class ExampleGroupMethods
alias :they :it
end
end
end

我将它包含在规范文件中,但我没有得到正确的模块路径。我查看了 rspec 代码库,但碰壁了,所以我认为我不太清楚自己在做什么。任何提示或资源将不胜感激。

最佳答案

您想使用 alias_example_to :

RSpec.configure do |c|
c.alias_example_to :they
end

这是 RSpec 的公共(public) API 的一部分。

关于ruby-on-rails - rspec 中的别名 'it',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12317558/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com