From 2cc0cac3efce92bf9d0e8636f2889c37ca9f57ab Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Fri, 26 Oct 2007 02:21:21 +0000 Subject: Introduce TestCase subclasses for testing rails applications allowing tests to be DRY'd up a bit and to provide a path toward tidying up our monkeypatching of test/unit. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8022 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/test_test.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index 305c5b6931..8fbe980eec 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -1,5 +1,6 @@ require "#{File.dirname(__FILE__)}/../abstract_unit" require "#{File.dirname(__FILE__)}/fake_controllers" +require "action_controller/test_case" class TestTest < Test::Unit::TestCase class TestController < ActionController::Base @@ -580,3 +581,34 @@ class CleanBacktraceTest < Test::Unit::TestCase assert !caught.backtrace.empty? end end + +class InferringClassNameTest < Test::Unit::TestCase + def test_determine_controller_class + assert_equal ContentController, determine_class("ContentControllerTest") + end + + def test_determine_controller_class_with_nonsense_name + assert_raises ActionController::NonInferrableControllerError do + determine_class("HelloGoodBye") + end + end + + def test_determine_controller_class_with_sensible_name_where_no_controller_exists + assert_raises ActionController::NonInferrableControllerError do + determine_class("NoControllerWithThisNameTest") + end + end + + private + def determine_class(name) + ActionController::TestCase.determine_default_controller_class(name) + end +end + +class CrazyNameTest < ActionController::TestCase + tests ContentController + def test_controller_class_can_be_set_manually_not_just_inferred + assert_equal ContentController, self.class.controller_class + end +end + -- cgit v1.2.3