expect(UserMailer).to receive(UserMailer.addon_purchased).with(event_order_id: @event_order.id)
我正在使用上面的代码。我需要做哪些更改才能使其正常工作?
我的邮件方法
@event_order = EventOrder.find(params[:event_order_id])
# TECH DEBT: why is .first relevant?
@ticket = @event_order.addons.first.event_ticket
if @ticket.blank?
Rails.logger.error "ticket purchased but no ticket found for Order# - #{@event_order.id}"
raise StandardError.new("ticket not found")
end
1条答案
按热度按时间lnvxswe21#
假设
addon_purchased
是一个类方法,您需要修改代码,如下所示参考:https://relishapp.com/rspec/rspec-mocks/docs/basics/expecting-messages