title: I want to assert for 404 in spec
body: <p>I want to test my app which redirects to a custom 404, 500 error pages. I turned on <em>config.consider_all_requests_local = false</em> in the <em>test.rb</em> file to check for the error pages.
  Now everything works fine and I am able to fill in the fields and assert with capybara if the path exists in rake routes eg:</p>
  
  <pre><code>visit signin_path 
  </code></pre>
  
  <p>the problem is if I give a wrong path like </p>
  
  <pre><code>visit signin_path + '/xyz' #xyz is incorrent
  </code></pre>
  
  <p>or</p>
  
  <pre><code>visit ('/wrongpage') 
  </code></pre>
  
  <p>to check for redirection to my custom error page, the test case gives an exception and does not proceed to the expect statement. This is the error:</p>
  
  <pre><code>Failure/Error: visit ('/wrongpage')
  
  ActionController::RoutingError:
    No route matches [GET] "/wrongpage"
  
  #then stack trace is printed here
  </code></pre>
  
  <p>I  also tried checking for </p>
  
  <pre><code>expect(page).to raise_error(ActiveRecord::RecordNotFound)
  </code></pre>
  
  <p>when I try to fetch a record with invalid id (like id = 'xyz' instead of integer, which gives a 500 error), same problem is present here, the execution stops and does not proceeds to the expect statement.</p>
  
  <p>I also tried looking on the internet for answers but didn't get what I was looking for, this (<a href="https://stackoverflow.com/a/25469175/2924562">https://stackoverflow.com/a/25469175/2924562</a>) was close but for </p>
  
  <pre><code>visit page_path
  </code></pre>
  
  <p>gives the following error:</p>
  
  <pre><code>    Failure/Error: visit page_path('wrongpage')
  
   NoMethodError:
     undefined method `page_path' for ....
  </code></pre>