如何测试方法别名 ruby [英] How to test method alias ruby
本文介绍了如何测试方法别名 ruby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何测试方法是否有别名?
How to test if if method has an alias?
假设我们有
Class Test
class << self
def a;end
alias :b :a
end
end
到目前为止,我想出了写这个规范的想法:
so far I came up with idea to write this spec:
it { expect(Test.b).to receive(:a) }
但我相信有更好的解决方案.有什么想法吗?
but I believe there is better solution. Any ideas?
推荐答案
您可以使用 对象#方法.
Test.method(:b) == Test.method(:a)
这篇关于如何测试方法别名 ruby的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文