无法弄清楚原因:
it "shifts/unshifts without O(n) copying" do
arr = RingBuffer.new
allow(arr.send(:store)).to receive(:[]=).and_call_original
8.times do |i|
arr.unshift(i)
end
# Should involve 8 sets to unshift, no more.
expect(arr.send(:store)).to have_received(:[]=).exactly(8).times
end
结果是:
“失败/错误:expect(arr.store).to have_received(:[]=).exactly(8).times # 预期已收到 []=,但该对象不是间谍或方法未被存根。 "