Permalink
Browse files

Add ActionDispatch::TestResponse tests.

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent 135d616 commit c5093799234de248d709e0bff1a28b4d29eb658e John Firebaugh committed with josevalim Aug 6, 2010
Showing with 21 additions and 0 deletions.
  1. +21 −0 actionpack/test/dispatch/test_response_test.rb
View
21 actionpack/test/dispatch/test_response_test.rb
@@ -0,0 +1,21 @@
+require 'abstract_unit'
+
+class TestResponseTest < ActiveSupport::TestCase
+ def assert_response_code_range(range, predicate)
+ response = ActionDispatch::TestResponse.new
+ (0..599).each do |status|
+ response.status = status
+ assert_equal range.include?(status), response.send(predicate),
+ "ActionDispatch::TestResponse.new(#{status}).#{predicate}"
+ end
+ end
+
+ test "helpers" do
+ assert_response_code_range 200..299, :success?
+ assert_response_code_range [404], :missing?
+ assert_response_code_range 300..399, :redirect?
+ assert_response_code_range 500..599, :error?
+ assert_response_code_range 500..599, :server_error?
+ assert_response_code_range 400..499, :client_error?
+ end
+end

0 comments on commit c509379

Please sign in to comment.