From cf13f31a74c46eb79032428d5efd176c4c35187c Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Fri, 28 Jun 2013 15:48:03 -0400 Subject: Add Response#unauthorized? helper This helper should come in handy when you want to test the authorization in your application. --- lib/rack/response.rb | 1 + test/spec_response.rb | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/rack/response.rb b/lib/rack/response.rb index 2beba7a8..2076aff0 100644 --- a/lib/rack/response.rb +++ b/lib/rack/response.rb @@ -122,6 +122,7 @@ module Rack def ok?; status == 200; end def bad_request?; status == 400; end + def unauthorized?; status == 401; end def forbidden?; status == 403; end def not_found?; status == 404; end def method_not_allowed?; status == 405; end diff --git a/test/spec_response.rb b/test/spec_response.rb index 7ba1e0e1..0ba17b15 100644 --- a/test/spec_response.rb +++ b/test/spec_response.rb @@ -216,6 +216,11 @@ describe Rack::Response do res.should.be.client_error res.should.be.bad_request + res.status = 401 + res.should.not.be.successful + res.should.be.client_error + res.should.be.unauthorized + res.status = 404 res.should.not.be.successful res.should.be.client_error -- cgit v1.2.3-24-ge0c7