How to check what is queued in ActiveJob using Rspec

后端 未结 7 1220
感动是毒
感动是毒 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:50

    There is a new rspec extension which makes your life easier.

    require 'rails_helper'
    
    RSpec.describe MyController do
      let(:user) { FactoryGirl.create(:user) }
      let(:params) { { user_id: user.id } }
      subject(:make_request) { described_class.make_request(params) }
    
      it { expect { make_request }.to enqueue_a(RequestMaker).with(global_id(user)) }
    end
    

提交回复
热议问题