From dca7efa67ec12b986ed03844af588055c9d8bdb9 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 17 Apr 2005 11:38:01 +0000 Subject: Deprecated the majority of all the testing assertions and replaced them with a much smaller core and access to all the collections the old assertions relied on. That way the regular test/unit assertions can be used against these. Added documentation about how to use it all. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1189 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/test_process.rb | 43 +++++++++++++++--------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'actionpack/lib/action_controller/test_process.rb') diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb index 6931e7cdcb..83cde64b85 100644 --- a/actionpack/lib/action_controller/test_process.rb +++ b/actionpack/lib/action_controller/test_process.rb @@ -1,5 +1,5 @@ -require File.dirname(__FILE__) + '/assertions/action_pack_assertions' -require File.dirname(__FILE__) + '/assertions/active_record_assertions' +require File.dirname(__FILE__) + '/assertions' +require File.dirname(__FILE__) + '/deprecated_assertions' if defined?(RAILS_ROOT) # Temporary hack for getting functional tests in Rails running under 1.8.2 @@ -94,17 +94,6 @@ module ActionController #:nodoc: end class TestResponse < AbstractResponse #:nodoc: - # the class attribute ties a TestResponse to the assertions - class << self - attr_accessor :assertion_target - end - - # initializer - def initialize - TestResponse.assertion_target=self# if TestResponse.assertion_target.nil? - super() - end - # the response code of the request def response_code headers['Status'][0,3].to_i rescue 0 @@ -126,10 +115,12 @@ module ActionController #:nodoc: end # was there a server-side error? - def server_error? + def error? (500..599).include?(response_code) end + alias_method :server_error?, :error? + # returns the redirection location or nil def redirect_url redirect? ? headers['location'] : nil @@ -281,8 +272,28 @@ module Test get(@response.redirected_to.delete(:action), @response.redirected_to.stringify_keys) end - def assigns(name) - @response.template.assigns[name.to_s] + def assigns(key = nil) + if key.nil? + @response.template.assigns + else + @response.template.assigns[key.to_s] + end + end + + def session + @response.session + end + + def flash + @response.flash + end + + def cookies + @response.cookies + end + + def redirect_to_url + @response.redirect_url end def build_request_uri(action, parameters) -- cgit v1.2.3