我有一个私有方法,它根据调用者方法返回一些东西:
private
def aPrivateMethod
r = nil
caller_method = caller[0][/`([^']*)'/, 1]
case caller_method
when "method_1"
r = "I was called by method_1"
when "method_2"
r = "I was called by method_2"
end
return r
end
在编写测试单元时,调用此私有方法的方法名称不会是 method_1 也不是 method_2,它将是以 test 开头的东西,我找不到从测试返回通过的解决方案。