From 44c64a612d3313b30a06f6f36e4260f53d4ed852 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Mon, 1 Aug 2005 21:28:17 +0000 Subject: Use raise instead of assert_not_nil in Test::Unit::TestCase#process to ensure that the test variables (controller, request, response) have been set git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1963 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/test_test.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index 570f92e6e4..fff1393872 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -177,4 +177,21 @@ HTML get :test_remote_addr assert_equal "192.0.0.1", @response.body end + + %w(controller response request).each do |variable| + %w(get post put delete head process).each do |method| + define_method("test_#{variable}_missing_for_#{method}_raises_error") do + remove_instance_variable "@#{variable}" + begin + send(method, :test_remote_addr) + assert false, "expected RuntimeError, got nothing" + rescue RuntimeError => error + assert true + assert_match %r{@#{variable} is nil}, error.message + rescue => error + assert false, "expected RuntimeError, got #{error.class}" + end + end + end + end end -- cgit v1.2.3