diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-08-29 16:16:59 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-08-29 16:16:59 +0000 |
commit | 92f1e26a1c9f48ac575414976012d6dfa127bdac (patch) | |
tree | fed6330bf337d763daf5a9d828cca09d9078496e | |
parent | c4d2691ace083c2211bfe2ee9464cf36b3b454ab (diff) | |
download | rails-92f1e26a1c9f48ac575414976012d6dfa127bdac.tar.gz rails-92f1e26a1c9f48ac575414976012d6dfa127bdac.tar.bz2 rails-92f1e26a1c9f48ac575414976012d6dfa127bdac.zip |
dispatcher test cosmetics
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4847 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | railties/test/dispatcher_test.rb | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/railties/test/dispatcher_test.rb b/railties/test/dispatcher_test.rb index 8fb19b173a..360a3e8023 100644 --- a/railties/test/dispatcher_test.rb +++ b/railties/test/dispatcher_test.rb @@ -24,30 +24,34 @@ class DispatcherTest < Test::Unit::TestCase def setup @output = StringIO.new ENV['REQUEST_METHOD'] = "GET" + Dispatcher.send(:preparation_callbacks).clear Dispatcher.send(:preparation_callbacks_run=, false) + + Object.const_set :ApplicationController, nil end def teardown + Object.send :remove_const, :ApplicationController ENV['REQUEST_METHOD'] = nil end def test_ac_subclasses_cleared_on_reset Object.class_eval(ACTION_CONTROLLER_DEF) - assert_equal 1, ActionController::Base.subclasses.length + assert_subclasses 1, ActionController::Base dispatch GC.start # force the subclass to be collected - assert_equal 0, ActionController::Base.subclasses.length + assert_subclasses 0, ActionController::Base end def test_am_subclasses_cleared_on_reset Object.class_eval(ACTION_MAILER_DEF) - assert_equal 1, ActionMailer::Base.subclasses.length + assert_subclasses 1, ActionMailer::Base dispatch GC.start # force the subclass to be collected - assert_equal 0, ActionMailer::Base.subclasses.length + assert_subclasses 0, ActionMailer::Base end @@ -78,9 +82,7 @@ class DispatcherTest < Test::Unit::TestCase [EMPTY_CONTENT, CONTENT_LENGTH_MISMATCH, NONINTEGER_CONTENT_LENGTH].each do |bad_request| $stdin = StringIO.new(bad_request) output = StringIO.new - assert_nothing_raised do - Dispatcher.dispatch(nil, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, output) - end + assert_nothing_raised { dispatch output } assert_equal "Status: 400 Bad Request\r\n", output.string end ensure @@ -88,7 +90,6 @@ class DispatcherTest < Test::Unit::TestCase end def test_preparation_callbacks - Object.const_set :ApplicationController, nil old_mechanism = Dependencies.mechanism a = b = c = nil @@ -117,12 +118,9 @@ class DispatcherTest < Test::Unit::TestCase assert_equal nil, a || b || c ensure Dependencies.mechanism = old_mechanism - Object.send :remove_const, :ApplicationController end def test_to_prepare_with_identifier_replaces - Object.const_set :ApplicationController, nil - a = b = nil Dispatcher.to_prepare(:unique_id) { a = b = 1 } Dispatcher.to_prepare(:unique_id) { a = 2 } @@ -130,12 +128,14 @@ class DispatcherTest < Test::Unit::TestCase Dispatcher.send :prepare_application assert_equal 2, a assert_equal nil, b - ensure - Object.send :remove_const, :ApplicationController end private - def dispatch - Dispatcher.dispatch(nil, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, @output) + def dispatch(output = @output) + Dispatcher.dispatch(nil, {}, output) + end + + def assert_subclasses(howmany, klass, message = klass.subclasses.inspect) + assert_equal howmany, klass.subclasses.size, message end end |