【发布时间】:2012-03-22 13:20:34
【问题描述】:
我有以下代码
def foo(bar)
bar.map(&:to_sym)
end
我想将期望设置为map 和&:to_sym。如果我这样做了
describe '#foo' do
it 'should convert to array of symbols' do
bar = %w(test1 test2)
bar.should_receive(:map).with(&:to_sym)
foo(bar)
end
end
它失败了
ArgumentError: no receiver given
有什么想法可以做到这一点吗?
【问题讨论】: