title: Testing for a 401 REST Response with Cucumber
body: <p>Question on how to check for a desired 401 REST response with Cucumber.</p>
  
  <p>Items of note:
   - This is not a Rails app.
   - Cucumber version is 1.3.17
   - I'm using rest_client 1.7.3:  <a href="https://github.com/rest-client/rest-client" rel="nofollow">https://github.com/rest-client/rest-client</a>
   - I have steps:</p>
  
  <pre><code>  When a GET request is made with no token
    Then status code should be '401'
  </code></pre>
  
  <p>And definitions:</p>
  
  <pre><code>  When /^a GET request is made with no token$/ do
      @response = RestClient.get "http://&lt;hidden&gt;"
    end
    Then /^status code should be '(\d+)'$/ do |code|
      expect(@response.code).to eq(code.to_i)
    end
  </code></pre>
  
  <p>The "Then" works fine for a '200' response, but I'm stopped from testing for a 401 because the run errors out on the "When" with, you guessed it, a 401 error.</p>
  
  <p>I've searched all over the interwebs for suggestions.  I've tried the @allow-rescue tag before my scenario (which seems to be a RAILS thing - but I tried it anyway.)  I haven't found a way to do a 401 test.</p>
  
  <p>Anyone have any ideas (other than looking at the failures in the test report and saying 'yup, those are supposed to fail'?)</p>
  
  <p>Thanks,
  Ed</p>