What's the best way to test delayed_job chains with rSpec?

后端 未结 3 747
天命终不由人
天命终不由人 2021-02-13 20:41

Currently when I have a delayed method in my code like the following:

CommentMailer.delay.deliver_comments(@comment, true)

I write something li

3条回答
  •  灰色年华
    2021-02-13 21:24

    describe '#perform' do
        subject do
          Delayed::Worker.delay_jobs = false
          proc { worker.perform() }
        end
    
        it { is_expected.to change { ActionMailer::Base.deliveries.length }.by(2) }
      end
    

    Set delayed job as false and u can test it like simple

提交回复
热议问题