title: How to test that a request does not return 500 error?
body: <p>I am trying to create an RSpec test which detects if a request can crash the controller, usually a 500 error. So I want to be able to distinguish between:</p>
  
  <pre><code> nil.invalid_method # raises NoMethodError
  </code></pre>
  
  <p>from</p>
  
  <pre><code> params.require(:required_parameter) # raises ActionController::ParameterMissing
  </code></pre>
  
  <p>in a controller in a generic way. When I do a <code>request</code>,<code>feature</code> or <code>controller</code> test it raises an exception:</p>
  
  <pre><code>describe "Post", type: :request do
    it 'does not crash when no params given' do
      post '/posts' # this line launches an exception
      expect(page).to_not have_http_status(500)
    end
  end
  </code></pre>
  
  <p>It seems that before RSpec (or Rails I don't know) had a different behaviour, similar to I'm looking for:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/24197661/rails-4-api-rspec-test-http-status-code-410">rails 4 api rspec test http status code 410</a></li>
  <li><a href="https://stackoverflow.com/questions/14995963/rspec-shows-different-status-code-than-browser">Rspec shows different status code than browser</a></li>
  <li><a href="https://stackoverflow.com/questions/18274709/how-to-use-http-status-code-symbols-in-rspec">How to use HTTP status code symbols in RSpec?</a></li>
  </ul>
  
  <p>How can I do this? Or how would you do?</p>
  
  <p>Thanks for your time.</p>