Skip to content
Browse files

Mock RailsFCGIHandler and Dispatcher to stop mocha deprecation warnings.

  • Loading branch information...
1 parent 6dbe90d commit 1a29a6717887ac1422bcce9067536987ee64f94d @josh josh committed Apr 21, 2008
Showing with 24 additions and 6 deletions.
  1. +24 −6 railties/test/fcgi_dispatcher_test.rb
View
30 railties/test/fcgi_dispatcher_test.rb
@@ -124,6 +124,24 @@ def test_uninterrupted_processing
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 @@ def setup
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 @@ def test_interrupted_via_HUP_when_not_in_request
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 @@ def test_interrupted_via_HUP_when_in_request
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 @@ def test_interrupted_via_USR1_when_not_in_request
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 @@ def test_interrupted_via_USR1_when_in_request
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 @@ def test_restart_via_USR2_when_in_request
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

0 comments on commit 1a29a67

Please sign in to comment.
Something went wrong with that request. Please try again.