【发布时间】:2017-09-27 10:56:48
【问题描述】:
#controller file
def update
@payment = Payment.find_by(reference_id: params[:reference_id])
if @payment.update(update_params)
@payment.do_something
end
end
当尝试指定是否调用了 do_something 方法时,由
expect(@payment).to receive(:do_something)
它说
expected: 1 time with any arguments
received: 0 times with any arguments
do_something 在我的支付类中。它实际上被调用了,但 rspec 说没有。
有什么想法吗?提前致谢
【问题讨论】:
标签: ruby-on-rails ruby rspec controller rspec-expectations