【发布时间】:2014-10-08 07:48:21
【问题描述】:
我有以下代码:
def initialize
yield method(:fulfill), method(:reject) if block_given?
end
我无法测试实际值 method(:fulfill) 和 method(:reject) 是否已生成,因为在生成值时我还没有访问该对象的权限。
因此我想这样测试它:
expect do |b|
PurePromise.new(&b)
end.to yield_with_args(PurePromise.instance_method(:fulfill), PurePromise.instance_method(:reject))
但是,UnboundMethod 不等于 Method,即使它引用相同的方法。
在匹配yield_with_args 的参数之前,有没有办法通过调用unbind 来转换产生值?
【问题讨论】: