我不熟悉使用 rspec should_receive 并且遇到很多问题,因为它“替换”了该方法。例如:
UserMailer.should_receive(:new_order).with(order)
为 nil:NilClass 提供未定义的方法 `deliver',因为 rspec 使该方法停止工作。我该如何处理?
我不熟悉使用 rspec should_receive 并且遇到很多问题,因为它“替换”了该方法。例如:
UserMailer.should_receive(:new_order).with(order)
为 nil:NilClass 提供未定义的方法 `deliver',因为 rspec 使该方法停止工作。我该如何处理?
您可以通过添加到您的方法链来处理这个问题,.and_call_original
如下所示:
UserMailer.should_receive(:new_order).with(order).and_call_original
如https://www.relishapp.com/rspec/rspec-mocks/v/2-13/docs/message-expectations/calling-the-original-method中所述,并在Is there a less intrusive alternative to Rspec's `应该接收?