title: How to raise an exception in an RSpec test
body: <p>I'm stuck on a test scenario.</p>
  
  <p>I have a controller method:</p>
  
  <pre><code>def update
    @object = Object.find params[:id]
    # some other stuff
    @object.save
    rescue ActiveRecord::StaleObjectError
      # woo other stuff
  end  
  </code></pre>
  
  <p>The first part I test with:</p>
  
  <pre><code>context '#update'
    let(:object) { double }
  
    it 'nothing fails' do
      # some other stuff
      expect(Object).to receive(:find).with('5').and_return(object)
      expect(object).to receive(:save).and_return(true)
      xhr :put, :update, id:5
      expect(response).to be_success
      expect(assigns(:object)).to eq(object)
    end
  end
  </code></pre>
  
  <p>Now I want to test the <code>ActiveRecord::StaleObjectError</code> exception. I want to stub it, but I didn't find any solution how to do this.</p>
  
  <p>So my question is, how to raise the <code>ActiveRecord::StaleObjectError</code> in an RSpec test?</p>