title: Testing after_commit with RSpec and mocking
body: <p>I have a model Lead and a callback: <code>after_commit :create, :send_to_SPL</code></p>
  
  <p>I am using Rails-4.1.0, ruby-2.1.1, RSpec.</p>
  
  <p>1) This spec is not passing:</p>
  
  <pre><code>context 'callbacks' do
    it 'shall call \'send_to_SPL\' after create' do
      expect(lead).to receive(:send_to_SPL)
      lead = Lead.create(init_hash)
      p lead.new_record? # =&gt; false
    end
  end
  </code></pre>
  
  <p>2) This spec is not passing too:</p>
  
  <pre><code>context 'callbacks' do
    it 'shall call \'send_to_SPL\' after create' do
      expect(ActiveSupport::Callbacks::Callback).to receive(:build)
      lead = Lead.create(init_hash)
    end
  end
  </code></pre>
  
  <p>3) This one is passing, but I think it is not testing after_commit callback:</p>
  
  <pre><code>context 'callbacks' do
    it 'shall call \'send_to_SPL\' after create' do
      expect(lead).to receive(:send_to_SPL)
      lead.send(:send_to_SPL)
    end
  end
  </code></pre>
  
  <p>What is the best way to test after_commit callbacks in Rails?</p>