diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-04-21 11:54:23 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-04-21 11:54:46 -0500 |
commit | 1a29a6717887ac1422bcce9067536987ee64f94d (patch) | |
tree | 96ae611179a04b4f1de117b46b30ae48315c24c7 /railties/test/fcgi_dispatcher_test.rb | |
parent | 6dbe90dd9b287ca383de9bae371614352a8646e7 (diff) | |
download | rails-1a29a6717887ac1422bcce9067536987ee64f94d.tar.gz rails-1a29a6717887ac1422bcce9067536987ee64f94d.tar.bz2 rails-1a29a6717887ac1422bcce9067536987ee64f94d.zip |
Mock RailsFCGIHandler and Dispatcher to stop mocha deprecation warnings.
Diffstat (limited to 'railties/test/fcgi_dispatcher_test.rb')
-rw-r--r-- | railties/test/fcgi_dispatcher_test.rb | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/railties/test/fcgi_dispatcher_test.rb b/railties/test/fcgi_dispatcher_test.rb index 6134211022..64d054d45c 100644 --- a/railties/test/fcgi_dispatcher_test.rb +++ b/railties/test/fcgi_dispatcher_test.rb @@ -124,6 +124,24 @@ end class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase + class ::RailsFCGIHandler + attr_accessor :signal + alias_method :old_gc_countdown, :gc_countdown + def gc_countdown + signal ? Process.kill(signal, $$) : old_gc_countdown + end + end + + class ::Dispatcher + class << self + attr_accessor :signal + alias_method :old_dispatch, :dispatch + def dispatch(cgi) + signal ? Process.kill(signal, $$) : old_dispatch + end + end + end + def setup @log = StringIO.new @handler = RailsFCGIHandler.new(@log) @@ -132,7 +150,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase def test_interrupted_via_HUP_when_not_in_request cgi = mock FCGI.expects(:each_cgi).once.yields(cgi) - @handler.expects(:gc_countdown).returns(lambda { Process.kill 'HUP', $$ } ) + @handler.expects(:signal).times(2).returns('HUP') @handler.expects(:reload!).once @handler.expects(:close_connection).never @@ -145,7 +163,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase def test_interrupted_via_HUP_when_in_request cgi = mock FCGI.expects(:each_cgi).once.yields(cgi) - Dispatcher.expects(:dispatch).with(cgi).returns( lambda { Process.kill 'HUP', $$ } ) + Dispatcher.expects(:signal).times(2).returns('HUP') @handler.expects(:reload!).once @handler.expects(:close_connection).never @@ -158,7 +176,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase def test_interrupted_via_USR1_when_not_in_request cgi = mock FCGI.expects(:each_cgi).once.yields(cgi) - @handler.expects(:gc_countdown).returns( lambda { Process.kill 'USR1', $$ } ) + @handler.expects(:signal).times(2).returns('USR1') @handler.expects(:exit_handler).never @handler.expects(:reload!).never @@ -172,7 +190,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase def test_interrupted_via_USR1_when_in_request cgi = mock FCGI.expects(:each_cgi).once.yields(cgi) - Dispatcher.expects(:dispatch).with(cgi).returns( lambda { Process.kill 'USR1', $$ } ) + Dispatcher.expects(:signal).times(2).returns('USR1') @handler.expects(:reload!).never @handler.expects(:close_connection).with(cgi).once @@ -185,7 +203,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase def test_restart_via_USR2_when_in_request cgi = mock FCGI.expects(:each_cgi).once.yields(cgi) - @handler.expects(:gc_countdown).returns( lambda { Process.kill 'USR2', $$ } ) + @handler.expects(:signal).times(2).returns('USR2') @handler.expects(:exit_handler).never @handler.expects(:reload!).never @@ -200,7 +218,7 @@ class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase def test_interrupted_via_TERM cgi = mock FCGI.expects(:each_cgi).once.yields(cgi) - Dispatcher.expects(:dispatch).with(cgi).returns(lambda { Process.kill 'TERM', $$ }) + Dispatcher.expects(:signal).times(2).returns('TERM') @handler.expects(:reload!).never @handler.expects(:close_connection).never |