title: How to ensure background jobs run in integration tests?
body: <p>I've got a integration test that is run through capybara. It visits a webpage, creates an object, and renders the results. When the object is created, the controller enqueues several jobs that create some related objects.</p>
  
  <p>When I run my integration test, I want to be able to examine the rendered page as if those jobs had finished. The 2 obvious solutions are:</p>
  
  <ol>
  <li>Set the queue adapter as :inline</li>
  <li>Manually execute/clear the enqueued jobs after creating the object.</li>
  </ol>
  
  <p>For 1), I've attempted to set the queue adapter in a <code>before(:each)</code> to :inline, but this does not change the adapter, it continues to use the test adapter (which is set in my test.rb config file):</p>
  
  <pre><code>before(:each) { ActiveJob::Base.queue_adapter = :inline }
  after(:each) { ActiveJob::Base.queue_adapter = :test }
  it "should work" do
    puts ActiveJob::Base.queue_adapter
  end
  </code></pre>
  
  <p>which outputs: <code>#&lt;ActiveJob::QueueAdapters::TestAdapter:0x007f93a1061ee0 @enqueued_jobs=[], @performed_jobs=[]&gt;</code></p>
  
  <p>For 2), I'm not sure if this is actually possible. <code>ActiveJob::TestHelpers</code> provides <code>perform_enqueued_jobs</code>, but this methods isn't helpful, as it seems to work only for jobs explicitly referenced in the passed in block.</p>