Permalink
Browse files

Add accessors for request and response so tests don't have to mess wi…

…th internal ivars
  • Loading branch information...
1 parent 5f808b8 commit 82514c2897a43ab58239af1fb24f8f0de2a0d989 @NZKoz NZKoz committed Apr 8, 2010
Showing with 8 additions and 0 deletions.
  1. +2 −0 actionpack/lib/action_controller/test_case.rb
  2. +6 −0 actionpack/test/controller/test_test.rb
@@ -284,6 +284,8 @@ class TestCase < ActiveSupport::TestCase
include ActionDispatch::TestProcess
include ActionController::TemplateAssertions
+ attr_reader :response, :request
+
# Executes a request simulating GET HTTP method and set/volley the response
def get(action, parameters = nil, session = nil, flash = nil)
process(action, parameters, session, flash, "GET")
@@ -189,6 +189,12 @@ def test_session_is_cleared_from_request_after_reset_session
assert_equal Hash.new, @request.session.to_hash
end
+ def test_response_and_request_have_nice_accessors
+ process :no_op
+ assert_equal @response, response
+ assert_equal @request, request
+ end
+
def test_process_with_request_uri_with_no_params
process :test_uri
assert_equal "/test_test/test/test_uri", @response.body

0 comments on commit 82514c2

Please sign in to comment.