How to check what is queued in ActiveJob using Rspec

后端 未结 7 1230
感动是毒
感动是毒 2021-01-31 08:33

I\'m working on a reset_password method in a Rails API app. When this endpoint is hit, an ActiveJob is queued that will fire off a request to Mandrill (our transactional email c

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-31 09:09

    The accepted answer no longer works for me, so I tried Michael H.'s suggestion in the comments, which works.

    describe 'whatever' do
      include ActiveJob::TestHelper
    
      after do
        clear_enqueued_jobs
      end  
    
      it 'should email' do
        expect(enqueued_jobs.size).to eq(1)
      end
    end
    

提交回复
热议问题