title: How to check what is queued in ActiveJob using Rspec
body: <p>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 client). I'm currently trying to write the tests to ensure that that the ActiveJob is queued correctly when the controller endpoint is hit. </p>
  
  <pre><code>def reset_password
    @user = User.find_by(email: params[:user][:email])
    @user.send_reset_password_instructions
  end
  </code></pre>
  
  <p>The send_reset_password_instructions creates some url's etc before creating the ActiveJob which's code is below:</p>
  
  <pre><code>class SendEmailJob &lt; ActiveJob::Base
    queue_as :default
  
    def perform(message)
      mandrill = Mandrill::API.new
      mandrill.messages.send_template "reset-password", [], message
    rescue Mandrill::Error =&gt; e
      puts "A mandrill error occurred: #{e.class} - #{e.message}"
      raise
    end
  end
  </code></pre>
  
  <p>At the moment we are not using any adapters for the ActiveJob, so I just want to check with Rspec that the ActiveJob is queued.</p>
  
  <p>Currently my test looks something like this (I'm using factory girl to create the user):</p>
  
  <pre><code>require 'active_job/test_helper'
  
  describe '#reset_password' do
    let(:user) { create :user }
  
    it 'should create an ActiveJob to send the reset password email' do
      expect(enqueued_jobs.size).to eq 0
      post :reset_password, user: { email: user.email }
      expect(enqueued_jobs.size).to eq 1
    end
  end
  </code></pre>
  
  <p>Everything works in reality, I just need to create the tests!</p>
  
  <p>I'm using ruby 2.1.2 and rails 4.1.6.</p>
  
  <p>I can't see any documentation or help anywhere on the web on how to test on this so any help would be greatly appreciated!</p>