How to check what is queued in ActiveJob using Rspec

后端 未结 7 1235
感动是毒
感动是毒 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 08:59

    In my opinion, ensure a job was enqueued when a request is performed is important. You can do it with the below solutions:

    Solution 1

    expect{ post your_api_here, params: params, headers: headers }
     .to have_enqueued_job(YourJob)
     .with(args)
    

    Solution 2

    expect(YourJob).to receive(:perform_later).once.with(args)
    post your_api_here, params: params, headers: headers
    
    

提交回复
热议问题