我正在尝试在 Rspec 中删除 ActiveJob 方法,但我无法真正解决它。我有一个 Mailchimp 的电子邮件发送类,它是 MailingListUnsubscribeJob
。调用的是:
MailingListUnsubscribeJob.set(wait: 20.days).perform_later(subject: user, list: "activation")
通常,当没有 set(wait: 20.days)
但我只有 perform_later
时,我会在 Rspec 中执行以下操作:
allow(MailingListUnsubscribeJob).to receive(:perform_later)
但是它不起作用。 有什么想法吗?
最佳答案
由于您已经在使用 RSpec,因此可以使用 rpec-activejob .
If your job uses
set(wait_until: time)
, you can use.to_run_at(time)
chain afterenqueue_a
call as well.
关于ruby-on-rails - 稍后在 Perform_later ActiveJob 上设置 stub ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40531681/